Quiz
quizz 3 harith
Create a free account to finish this quiz
Save your progress and see your final score.
Already have an account? Sign in
Questions in this quiz (17)
1What is the final value of x when the code int x; for(x=0; x<10; x++) {} is run?
- A10
- B9
- C0
- D1
2int main ()
{
int x = 20, y = 35;
x = y++ + x++;
y = ++y + ++x;
printf ("%d %d n", x, y);
}- A55 92
- B56 93
- C57 94
- Dnone
3#include <stdio.h>
int main()
{
int i = 1024;
for (; i; i >>= 1)
printf("GeeksQuiz");
return 0;
}
How many times will GeeksQuiz be printed in the above program?- A10
- B11
- Cinfinity
- Derror
4#include<stdio.h>
int main()
{
int n;
for (n = 9; n!=0; n--)
printf("n = %d", n--);
return 0;
}
What is the output- A9 7 5 3 1
- B9 8 7 6 5 4 3 2 1
- Cinfinity
- D9 7 5 3
5Output?
#include <stdio.h>
int main()
{
int c = 5, no = 10;
do {
no /= c;
} while(c--);
printf ("%dn", no);
return 0;
}- A1
- Bruntime error
- C0
- Dcompile error
6# include <stdio.h>
int main()
{
int i = 0;
for (i=0; i<20; i++)
{
switch(i)
{
case 0:
i += 5;
case 1:
i += 2;
case 5:
i += 5;
default:
i += 4;
break;
}
printf("%d ", i);
}
return 0;
}- A5 10 15 20
- B7 12 17 22
- C16 21
- Dcompile error
7#include <stdio.h>
int main()
{
int i = 3;
switch(i)
{
printf("Outside ");
case 1: printf("Geeks");
break;
case 2: printf("Quiz");
break;
defau1t: printf("GeeksQuiz");
}
return 0;
}- AOutside GeeksQuiz
- BGeeksQuiz
- CNothing gets printed
8How many times GeeksQuiz is printed
#include<stdio.h>
int main()
{
int i = -5;
while (i <= 5)
{
if (i >= 0)
break;
else
{
i++;
continue;
}
printf("GeeksQuiz");
}
return 0;
}- A10
- B5
- Cinfinity
- D0
9#include <stdio.h>
int main()
{
int i = 3;
while (i--)
{
int i = 100;
i--;
printf("%d ", i);
}
return 0;
}- Ainfinity loop
- B99 99 99
- C99 98 97
- D2 2 2
10#include <stdio.h>
int main()
{
int x = 3;
if (x == 2); x = 0;
if (x == 3) x++;
else x += 2;
printf("x = %d", x);
return 0;
}- Ax=4
- Bx=2
- Ccomplile error
- Dx=0
11With respect to following “for” loops in C, pick the best statement Assume that there is a prior declaration of 'i' in all cases
for (i < 10; i = 0 ; i++) // (i)
for (i < 10; i++ ; i = 0) // (ii)
for (i = 0; i < 10 ; i++) // (iii)
for (i = 0; i++ ; i < 10) // (iv)
for (i++; i = 0 ; i < 10) // (v)
for (i++; i < 0 ; i = 10) // (vi)- AAll the above “for” loops would compile successfully
- BAll the above “for” loops would compile successfully. Except (iii), the behaviour of all the other “for” loops depend on compiler implementation
- COnly (iii) would compile successfully
- DOnly (iii) and (iv) would compile successfully.
- EOnly (iii) and (iv) would compile successfully but behaviour of (iv) would depend on compiler implementation.
12What’s going to happen when we compile and run the following C program?
#include "stdio.h"
int main()
{
int i = 1, j;
for ( ; ; )
{
if (i)
j = --i;
if (j < 10)
printf("GeeksQuiz", j++);
else
break;
}
return 0;
}- ACompile Error
- BNo compile error but it will run into infinite loop printing GeeksQuiz.
- CNo compile error and it’ll print GeeksQuiz 10 times
- DNo compile error but it’ll print GeeksQuiz 9 times
13What’s going to happen when we compile and run the following C program?
#include "stdio.h"
int main()
{
int j = 0;
for ( ; j < 10 ; )
{
if (j < 10)
printf("Geeks", j++);
else
continue;
printf(“Quiz”);
}
return 0;
}- ACompile Error due to use of continue in for loop
- BNo compile error but it will run into infinite loop printing Geeks.
- CNo compile error and it’ll print GeeksQuiz 10 times followed by Quiz once.
- DNo compile error and it’ll print GeeksQuiz 10 times
14What will be the output of the following C code?
#include <stdio.h>
main( )
{
int i;
for ( i=0; i<5; i++ )
{
int i = 10;
printf ( "%d ", i );
i++;
}
return 0;
}- A10 11 12 13 14
- B10 10 10 10 10
- C0 1 2 3 4
- Dcomilpation error
15#include <stdio.h>
int main()
{
int i;
if (printf("0"))
i = 3;
else
i = 5;
printf("%d", i);
return 0;
}
Predict the output of above program- A3
- B5
- C03
- D05
16#include<stdio.h>
int main()
{
int n;
for (n = 9; n!=0; n--)
printf("n = %d", n--);
return 0;
}- A9 7 5 3 1
- B9 8 7 6 5 4 3 2 1
- Cinfinity
- D9 7 5 3
17Output?
#include <stdio.h>
int main()
{
int c = 5, no = 10;
do {
no /= c;
} while(c--);
printf ("%dn", no);
return 0;
}- A1
- Bruntime error
- C0
- Dcompiler error
Information
- Description
- Quiz on quizz 3 harith, created by Harith Lakmith on 22/08/2018.
- Author
- Harith Lakmith
- Language
- English
- Views
- 165
- Rating
- No ratings yet Rate this quiz
More on Conditionals and Loops