Class Test 5
Class Test 5
Time : 50 m M. mark:25
Output finding: 2 marks each 5. #include<iostream.h>
1. #include<stdio.h> void main()
#include<iostream.h> { int i = 0, x = 0;
void main() do
{ int s1,s2, num; { if ( i % 5 == 0)
s1 = s2 = 0; { x++;
cin >> num; cout << x;
for(int x=0; x<11; x++) }
{ if (num > 0) s1 += num; else s2 -= num; } ++i;
cout<<s1<<s2; } while(i < 20);
} cout << "\n"<< x;
* if input is (i) 5 (ii) -5 }
6. Write menu driven program to ask user choice 1. For
2. #include<iostream.h> area of triangle., 2. For area of circle, 3. For area of
void main() square and 4. For exit. Repeat the work till user choice is
{ long NUM=1234543; yes. (3)
int F=0, S=0;
do 7. What is the difference between break, continue and exit.
{ Explain with example. 3
int Rem = NUM%10;
if (Rem % 2 != 0) 8. What do you mean by empty loop. Give example. 1
F+=Rem;
else 9. Write the difference between while and do-while with
S+=Rem; example. 2
NUM /=10;
}while (NUM>0); 10. Name the library used for following functions: 1
cout << F-S; (a) exit(0) (c) setw()
}
11. State the output of the following code: 1
3. #include <iostream.h> i=10;
#include <conio.h> while(i)
void main() cout<<i--;
{ char code; cout<<”\n Thank you”;
cin >> code;
switch(code) 12. What will be the result of 4
{ (i) u1 && u2
case 'A' : cout<<"Accountant"; break; (ii) u1 || u2
case 'C' : (iii) ! u1
case 'G' : cout<<"Grade IV "; break; (iv) ! ! u1
case 'F' : cout<<"Financial Advisor ";
} if unsigned int u1 = 0, u2 = 7 ;
}
*if input is (i) C (ii) K
4. #include <iostream.h>
void main()
{ int x, z;
cin >> x;
for (int y=0; y<x; y++)
{ z = y; }
cout << z;
}
* if input is 4