Upload
syed-hassanyousaf
View
27
Download
3
Embed Size (px)
Citation preview
Mohammad Ali Jinnah University, Islamabad Campus
Quiz#9
Course Title Computer Programming (for Engineers)Instructor Maryam KausarWeightage 2%
Question 1: Write a program to sort an array of 5 integers which are { 1,5,3,2,4}.
Using bubble sort.
Question 2: Determine the output of the following program.
#include <iostream>using namespace std;int main() {
int myarr[2][3];
for(int r = 0; r < 2; r++) { for(int c = 0; c < 3; c++) { myarr[r][c] = r*c+1; } } for(r = 0; r < 2; r++) { for(int c = 0; c < 3; c++) { cout << myarr[r][c] << " "; } cout << endl;
}return 0;}
1 1 1 1 2 3
Question 3: Determine the output of the following program.
#include <iostream>using namespace std;
int minArray(int arr[][5], int rowCap, int colCap) { int m = arr[0][0];
for (int r = 0; r < rowCap; r++) for (int c = 0; c < colCap; c++) if (arr[r][c] < m) m = arr[r][c];
return m;}
int main() {int x[3][5] = { {13,4,35,22,3}, {32,3,7,3,2},
{3,4,4,4,2}}; cout << minArray(x, 3, 5) << endl; return 0;}
2
Question 4: Using multiple dimension arrays write a program that will take students quiz marks and display the minimum marks.
Solution present in lecture slide.