The questions and answers for quiz #8 in the computer programming (for engineers) course taught by maryam kausar at mohammad ali jinnah university. The quiz covers array declaration, output determination of given programs, and sum calculation of an array of integers.
Download Quiz #8 in Computer Programming (for Engineers) at Mohammad Ali Jinnah University 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:What are the elements required to declare an array?
Question 2: Determine the output of the following program.
using namespace std;
int main()
const int size =5;
int value[size] = (1, 2, 3);
double junk[size];
cout<<end1;
for(int i=0; i<size ; i++)
cout<< โ โ<<
setw(12)<<values[i];
cout<<end1;
for(int i=0; i<size ; i++)
cout<< โ โ<<
setw(12)<<junk[i];
cout<<end1;
return 0;
docsity.com
Question 3: Determine the output of the following program.
#include using namespace std; int bill [] = {16, 2, 77, 40, 12071}; int n, result=0; int main () { for ( n=0 ; n<5 ; n++ ) { result += bill[n]; } cout << result; return 0; }
Question 4: Determine the output of the following program.
#include using namespace std; int main() { const int max = 10; int number[max]; int sum = 0; cout << "Please type 10 integers.\n"; for( int i = 0; i < max; i++ ) { cout << "Number " << i + 1 << ": "; cin >> number[i]; sum += number[i]; } cout << "\n\nThe sum of these numbers is " << Sum << "\n\n"; return 0; } Please type 10 integers. Number 1: 120 Number 2: 42 Number 3: 75 Number 4: 38 Number 5: 904 Number 6: 6 Number 7: 26 Number 8: 55 Number 9: 92 Number 10: 20 The sum of these numbers is 1378