0% found this document useful (0 votes)
29 views1 page

Class Test 5

The document contains sample C++ code snippets and questions testing concepts like loops, functions, conditional statements, data types, operators etc. There are 12 questions in total ranging from writing code for simple programs to explaining concepts like break, continue and empty loops. The questions cover basic to intermediate level C++ programming concepts.

Uploaded by

daksh.gupta31983
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views1 page

Class Test 5

The document contains sample C++ code snippets and questions testing concepts like loops, functions, conditional statements, data types, operators etc. There are 12 questions in total ranging from writing code for simple programs to explaining concepts like break, continue and empty loops. The questions cover basic to intermediate level C++ programming concepts.

Uploaded by

daksh.gupta31983
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Class Test 5 (C++) XI A

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

You might also like