C Programming Practice - Test 5

20 Questions | Attempts: 101
Share

SettingsSettingsSettings
C Programming Practice - Test 5 - Quiz

. Dear Learner, This Assessment consists of questions to test your understanding on - C Programming You may attempt the same and clarify doubts in WP Group. / With your Faculty Member Regards, Team SHIVAM


Questions and Answers
  • 1. 
    Point out the error, if any in the for loop #include int main() { int i=1; for(;;) { printf("%d\n", i++); if(i>10) break; } return 0; }
    • A. 

      There should be a condition in the for loop

    • B. 

      The two semicolons should be dropped

    • C. 

      The for loop should be replaced with while loop

    • D. 

      No error

  • 2. 
    Pick the right alternative main() { int c=- -2; while(--c) printf("c=%d",c); }
    • A. 

      C=99

    • B. 

      C=1

    • C. 

      No Output

    • D. 

      C=2

  • 3. 
    What will be the output? main() { char s[ ]="m"; int i; for(i=0;s[ i ];i++) printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]); }
    • A. 

      Mmmm

    • B. 

      Compiler error

    • C. 

      No Output

    • D. 

      M01m

  • 4. 
    What main() { int i=0; while(+(+i--)!=0) i-=i++; printf("%d",i); }
    • A. 

      0

    • B. 

      1

    • C. 

      -1

    • D. 

      -2

  • 5. 
    Void main() { static int i; while(i2)?i++:i--; printf(“%d”, i); }
    • A. 

      32767

    • B. 

      0

    • C. 

      1

    • D. 

      Compiler error

  • 6. 
    What is the output of this program? void main() { int i=122; while(i!=97) i--; while(i>65) i--; printf(“%c”,i); }
    • A. 

      65

    • B. 

      A

    • C. 

      B

    • D. 

      B

  • 7. 
    What is the output of this program? void main() { int i=99; while(i
    • A. 

      100

    • B. 

      A

    • C. 

      D

    • D. 

      C

  • 8. 
    #include void main() { double k = 0; for (k = 0.0; k < 3.0; k++); printf("%lf", k); }
    • A. 

      4.000000

    • B. 

      3.000000

    • C. 

      2.000000

    • D. 

      Run time error

  • 9. 
    What is the output of this program? void main() { int x=1; x=!x; while(x!=!x) { printf(“%d”,i); } }
    • A. 

      0

    • B. 

      1

    • C. 

      -1

    • D. 

      Logical Error

  • 10. 
    What is the output of this program? void main() { int k; for(k=10; k%2! =0 && k%3!=0;k--) if(k==1) break; printf(“%d”,k); }
    • A. 

      Compiler error

    • B. 

      10

    • C. 

      7 5

    • D. 

      Prime digits

  • 11. 
    What is the output of this program? void main() { long int i=3; while(++i
    • A. 

      0

    • B. 

      4

    • C. 

      3

    • D. 

      No output

  • 12. 
    What is the output of this program? void main() { int i, j; for(i=0,j=20; i!=j; i++,j--) { printf(“%c”,i+48); } }
    • A. 

      Digits

    • B. 

      Prime digits

    • C. 

      Compiler error

    • D. 

      No output

  • 13. 
    What is the output of this program? void main() { int i=0, j=1; while(i==!j) { printf(“%d %d”,!i,!j); i++; j++; } }
    • A. 

      0 0

    • B. 

      0 1

    • C. 

      1 0

    • D. 

      1 1

  • 14. 
    What is the output of this program? void main() { int k; for(k=32768; k
    • A. 

      -32768

    • B. 

      32768

    • C. 

      -32767

    • D. 

      32767

  • 15. 
    The following code stands for what? void main() { int m=60,n=25; if(m!=n) { while(m>n) m-=n; interchange(m,n); // assume the function interchange content of m & n } printf(“%d”,m); }
    • A. 

      LCM(m,n)

    • B. 

      GCD(m,n)

    • C. 

      Max(m,n)

    • D. 

      Min(m,n)

  • 16. 
    Void main() { int a[5] = {1, 2, 3, 4, 5}; int i; for (i = 0; i < 5; i++) if ((char)a[i] == '5') printf("%d\n", a[i]); else printf("FAIL\n"); }
    • A. 

      The compiler will flag an error

    • B. 

      Program prints 5

    • C. 

      Program will compile and print the ASCII value of 5

    • D. 

      Program prints FAIL for 5 times

  • 17. 
    What is the output of this program? #include #include void main() { printf(“%d”, (2*(1+rand()%4)); }
    • A. 

      Any even digit

    • B. 

      Any odd digit

    • C. 

      Any prime number

    • D. 

      Any perfect no

  • 18. 
    What is the output of this program? void main() { int i=0,j=1,k; while(i
    • A. 

      Prime nos

    • B. 

      Perfect nos

    • C. 

      Fibonacci nos

    • D. 

      Armstrong no

  • 19. 
    Fill in the blank: #include #include void main() { int i,n; scanf(“%d”,&n); for(i=2;isqrt(n)) printf(“%d is ________”,n); }
    • A. 

      Armstrong no

    • B. 

      Peterson no.

    • C. 

      Perfect no

    • D. 

      Prime no

  • 20. 
    What is the output of this program? void main() { int i; for(i=10;--i%3==0;i--) printf(“%d”,i); }
    • A. 

      9 6 3

    • B. 

      9 6

    • C. 

      9

Back to Top Back to top
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.