Sorting an Array-Introduction to Programming-Quiz Solution, Exercises of Computer Programming

This quiz was taken by Sir Raza Muhammad at Quaid-i-Azam University for Introduction to Programming course. It includes: Program, Sort, Array, Integers, Bubble, Sort, Multiple, Dimension, Solution, Sequence

Typology: Exercises

2011/2012

Uploaded on 07/13/2012

asim.amjid
asim.amjid 🇵🇰

4.4

(47)

41 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Mohammad Ali Jinnah University, Islamabad Campus
Quiz#9
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 <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
docsity.com
pf2

Partial preview of the text

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