Download Sorting an Array-Introduction to Programming-Quiz Solution and more Exercises Computer Programming in PDF only on Docsity!
Mohammad Ali Jinnah University, Islamabad Campus
Quiz#
Course Title Computer Programming (for Engineers)
Instructor Maryam Kausar
Weightage 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 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; }
docsity.com
Question 3: Determine the output of the following program.
#include 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 ; }
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.
docsity.com