100% found this document useful (2 votes)
48 views

CS (Boys) - Programming Fundamentals (CC-112)

The document contains a midterm exam for a Programming Fundamentals course with 4 multiple choice questions and 1 long answer question. Question 1 has 4 code snippets and asks to find the output of each. Question 2 asks about how to find the length of an array and the difference between fixed and dynamic arrays. Question 3 identifies errors in 4 code snippets and asks to remove the errors and explain them. Question 4 asks to design a program to take marks for 2 sections of students, store in arrays, and return the maximum and minimum marks.

Uploaded by

Shahmeer KazMi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
48 views

CS (Boys) - Programming Fundamentals (CC-112)

The document contains a midterm exam for a Programming Fundamentals course with 4 multiple choice questions and 1 long answer question. Question 1 has 4 code snippets and asks to find the output of each. Question 2 asks about how to find the length of an array and the difference between fixed and dynamic arrays. Question 3 identifies errors in 4 code snippets and asks to remove the errors and explain them. Question 4 asks to design a program to take marks for 2 sections of students, store in arrays, and return the maximum and minimum marks.

Uploaded by

Shahmeer KazMi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Govt.

Graduate College, Pasrur


Midterm Exam

Course: Programming Fundamentals Course Code: CC-112 Max. Time: 90 Min.


nd
Department: Computer Science Semester: 2 Max. Marks: 25
Slot: 09:00 - 10:30 AM Instructor: Prof. Shahmeer Date: 02-09-2023
No Query will be entertained during the time of paper. Read each question on the sheet carefully and fulfill
it’s requirements accordingly.

Question No. 01: Find the output of the following Codes. (4*2=08)
a #include<iostream> b #include<iostream>
using namespace std; using namespace std;
int main() int i = 20;
{ int main()
int number = 10; {
if(number>10) int i = 10;
cout<<"Number is greater than 10"<<endl; for(int i=15;i<16;i++)
cout<<"Number is Integer"<<endl; {
cout<<"For Loop Executed"<<endl;
if(number=10) }
cout<<"Value of the number is 10"<<endl; cout<<"The value of vriable is "<<i<<endl;
cout<<"The value of vriable is "<<::i<<endl;
return 0;
} return 0;
}
c #include<iostream> d #include<iostream>
using namespace std; using namespace std;
int main() int main()
{ {
int Arr[1][2][3]={{{3,4,7},{2,5,6}}}; for(int i=0;i<5;i++)
int temp=0; cout<<i<<endl;
temp = Arr[0][0][1]; cout<<"Loop Ended"<<endl;
Arr[0][0][1] = Arr[0][1][1]; return 0;
Arr[0][1][1] = temp; }

cout<<Arr[0][0][1]<<endl;
cout<<Arr[0][1][1];
return 0;
}

Question No. 02: Satisfy the Following Questions. (2+2=04)


a. How do you find the length of an array in C++?
b. Explain the Difference between declaring an array with a fixed size and using dynamic memory allocation for an
array with example?
Question No. 03: Identify Errors in the following codes and remove them for the proper execution of
the program also elaborate the errors in the code. (4*2=08)

a 1. #include<iostream> b 1. #include<iostream>
2. using namespace std; 2. using namespace std;
3. int main() 3. int main()
4. { 4. {
5. int Arr[5] = {1,1.5,2,2.5,3,3.5}; 5. for(int i =0;i<5;j++);
6. cout<<"Value of Array: " 6. {
7. cout<<Arr[5]; 7. cout<<"Loop Executed<<endl;
8. }
8. return 0; 9. cout<<"Loop Terminated"<<endl;
9. } 10. return 0;
11. }
c 1. #include<iostream> d 1. #include<iostream>
2. using namespace std; 2. using namespace std;
3. int main() 3. int main()
4. { 4. {
5. char Arr[3]; 5. bool gcp = false;
6. Arr[0] = "C"; 6. if(gcp=true);
7. Arr[1] = "+" 7. {
8. Arr[2] = '+'; 8. cout<<"No Spelling Mistake"<<endl;
9. cout<<"Good to go"<<endl;
9. for(int i=0;i<=3;i++) 10. }
10. { 11. else()
11. cout<<Arr[i]<<endl; 12. {
12. } 13. cout<<"Speling Mistake"<<endl;
13. cout<<"Array of Character 14. cout<<"Corret the spellings"<<endl;
Printed"<<endl; 15. }
14. return 0; 16. return 0;
15. } 17. }

Question No. 04: Solve the given problems. (05)


You have to design a program for Department of Computer Science Section A and B of 2 nd Semester, take the marks of
each student in the Programming Fundamentals Subject out of 25 and return the Maximum and the Minimum marks
scored by any student either in A Section or in B Section using Array concepts. You have to take minimum 10 students in
each Section.

You might also like