Assignment 02

  • April 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Assignment 02 as PDF for free.

More details

  • Words: 204
  • Pages: 1
Assignment 2  Due: Sunday, April 19, 2009 at 11:55 PM 

1

Write a MIPS program to sort a given (hard-coded) array by recursive bubble sort.

2

Write a program to recursively calculate the Fibonacci number for a given input number n i.e. if the user inputs 9, then the output must be the 9th Fibonacci number, which is 34 (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55). The first two Fibonacci numbers are 0 and 1 and each remaining number is the sum of the previous two: Fn = Fn-1 + Fn-2

3

Write a MIPS code to add two 3x3 matrices as given below

#include using namespace std; int main() { int matA[3][3] = {{1,2,3},{4,5,6},{7,8,9}}; int matB[3][3] = {{9,8,7},{6,5,4},{3,2,1}}; int matADD[3][3]; for(int r = 0; r < 3; r++) { for(int c = 0; c < 3; c++) { matADD[r][c] = matA[r][c] + matB[r][c]; cout<<matADD[r][c]<<","; } cout<<endl; } return 0; }

4

Write a MIPS program that initializes with the following array: myAge .word 40, 30, 30, 20, 60, 10, 14, 40, 44, 45, 10, 25, 39, 29, 47, 59, 73, 78, 80, 100 Calculate how many people are in their forties, less than forty and greater than 49.

Related Documents

Assignment 02
November 2019 7
Assignment 02
April 2020 4
Assignment 02.docx
May 2020 2