ASSIGNMENT
(LOOPS AND OPERATORS FOR CLASS XI)
MCQ'S
Q1. What will be the output of the C++ program?
void main()
{
int i = 5;
int a = ++i + ++i + ++i;
cout<
}
Ans: 21
Q2. What will be the output of the C++ program?
void main()
{
int i = 5;
int a = ++i + ++i + ++i + ++i;
cout<}
A. 21 B. 6 C. 11 D. 30
Q3. What will be the output of the C++ program?
void main()
{
int i = 5;
int a = --i + --i;
cout<}
A. 8 B. 5 C. 7 D. 6
Q4. What will be the output of the C++ program?
void main()
{
int i = 5;
int a = --i + --i + --i;
cout<}
A. 8 B. 9 C. 7 D. 6
Q5. What will be the output of the C++ program?
void main()
{
int i = 5;
int a = --i - --i - --i - --i;
cout<
}
A. -2 B. -3 C. -1 D. -4
Q6. What will be the output of the C++ program?
void main()
{
int a = 2, b = 2, c = 0, d = 2, m;
m = a++ && b++ && c++ | | d++;
cou<}
A. Compilation error B. 3 3 1 3 1 C. 3 3 1 3 0 D. some garbage value
Q7. What will be the output of the C++ program?
void main()
{
int i = 5;
int a = --i + ++i - i-- + --i;
cout<}
A. 7 B. 9 C. 8 D. 10
Q8. What will be the output of the C++ program?
void main(){
int i = 0, j = 0;
if(i++ == j++)
cout<< i--<<" "<< j--;
else
cout<
}
A. 0 0 B. 0 1 C. 1 0 D. 1 1
Q9. What will be the output of the C++ program?
void main()
{
int i = 5, j = 6, k = 7;
if(i > j == k)
cout<< i++<<" "<<++j<<" "<<--k br=""> else
cout<}
A. 5 7 6 B. 5 6 7 C. 6 6 6 D. 5 7 7--k>
Q10. What will be the output of the C++ program?
void main(){
int i = 5;
while( i > 0){
cout<<"Loop ";
--i;
}
}
A. Loop Loop Loop Loop Loop Loop
B. Loop Loop Loop Loop Loop
C. Loop Loop Loop Loop
D. Loop Loop Loop
Q12. What will be the output of the C++ program?
void main()
{
int i = 4, j = 7;
while(i < j)
{
cout<<"Loop";
++i;
--j;
}
}
A. Loop B. Loop Loop C. Loop Loop Loop D. Infinite Loop