Uploaded by GordonCollege BSIT

Math-206 Mid Paper

advertisement
Government Gordon College Rawalpindi
Mid-term Examination Fall-2019
MATH-206
Programming Language for Mathematicians
Q1.
Maximum Marks : 20
Time allowed : 01:30 Hours
Trace the output of following code.
(2x5=10) 10
#include <iostream>
using namespace std;
int main() {
int num = 23;
num++;
switch (num%2+13+num)
{
num++;
case 1:
num++;
case 2:
num++;num++;
case 3:
num++;num++;num++;
case 3+1:
num++;num++;num++;num++;
default:
num++;
}
cout<<num;
}
b.
c.
#include <iostream>
using namespace std;
int main()
{
if (1) {
label_1: cout<<"Hello ";
goto label_2;
}
else {
goto label_1;
label_2: cout<<"Geeks";
}
return 0;
}
d.
d.
#include <iostream>
using namespace std;
int main() {
short a;
for (a = 32767; a < 32770; a++)
cout << a << "\n";
return 0;
}
a.
#include<iostream>
using namespace std;
int main() {
int n1=1;
float n2=11.2345;
switch((int)(n1 > n2))
{
case 0:
cout<<n2<<”is the
largest”<<endl;
break;
case 1:
cout<<n1<<”is the
largest”<<endl;
default:
cout<<n1<<“is the
largest”<<endl;
}
#include <iostream>
using namespace std;
#define MAX 20
#define MIN 5
int main()
{
int i=MIN;
START:
cout << i++ << "\n";
cout << ++i << "\n";
if (i<=MAX)
goto START;
return 0;
}
Q2.
Write a program that inputs the total marks of students of a whole class (using goto statement)
and calculates and displays the percentage (rounded off) of student.
Your program will then display the grade of student based on following criteria:
 If marks are 81 – 100% then grade is A
 If marks are 61 – 80% then grade is B
 If marks are 41 – 50% then grade is C
 If marks are < 40%
then grade is D
Students are allocated scholarship on following criteria:
 If marks are 91 – 100% then scholarship is 100%
 If marks are 81 – 90% then scholarship is 80%
 If marks are 71 – 80% then scholarship is 60%
 If marks are 61 – 70% then scholarship is 40%
 If marks are 51 – 60% then scholarship is 20%
 If marks are 41 – 50% then scholarship is 10%
 If marks are < 40%
then NO scholarship
At the end program displays
 Average percentage of whole class with total number of students.
 Total number of passed and failed students.
 Total number of students who secured 100% scholarship.
 Total number of students who secured more than 50% scholarship.
Total number of students who secured less than 50% scholarship.
10
Download