# Math-206 Mid Paper ```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 &lt;iostream&gt;
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&lt;&lt;num;
}
b.
c.
#include &lt;iostream&gt;
using namespace std;
int main()
{
if (1) {
label_1: cout&lt;&lt;&quot;Hello &quot;;
goto label_2;
}
else {
goto label_1;
label_2: cout&lt;&lt;&quot;Geeks&quot;;
}
return 0;
}
d.
d.
#include &lt;iostream&gt;
using namespace std;
int main() {
short a;
for (a = 32767; a &lt; 32770; a++)
cout &lt;&lt; a &lt;&lt; &quot;\n&quot;;
return 0;
}
a.
#include&lt;iostream&gt;
using namespace std;
int main() {
int n1=1;
float n2=11.2345;
switch((int)(n1 &gt; n2))
{
case 0:
cout&lt;&lt;n2&lt;&lt;”is the
largest”&lt;&lt;endl;
break;
case 1:
cout&lt;&lt;n1&lt;&lt;”is the
largest”&lt;&lt;endl;
default:
cout&lt;&lt;n1&lt;&lt;“is the
largest”&lt;&lt;endl;
}
#include &lt;iostream&gt;
using namespace std;
#define MAX 20
#define MIN 5
int main()
{
int i=MIN;
START:
cout &lt;&lt; i++ &lt;&lt; &quot;\n&quot;;
cout &lt;&lt; ++i &lt;&lt; &quot;\n&quot;;
if (i&lt;=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 &lt; 40%
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 &lt; 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
```