C Programming Practice - Test 3

20 Questions | Total Attempts: 171

SettingsSettingsSettings
C Programming Quizzes & Trivia

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


Questions and Answers
  • 1. 
    What will be output if you will compile and execute the following c code? void main() { float a=5.2; if(a==5.2) printf("Equal"); else if(a
    • A. 

      Less than

    • B. 

      Equal

    • C. 

      Greter than

    • D. 

      Compilation error

  • 2. 
    What will be output if you will compile and execute the following c code? void main() { int a=2; if(a==2) { a=~a+2
    • A. 

      -3

    • B. 

      -2

    • C. 

      1

    • D. 

      Compilation error

  • 3. 
    What will be output if you will compile and execute the following c code? void main() { int i=10; static int x=i; if(x==i) printf("Equal"); else if(x>i) printf("Greater than"); else printf("Less than"); }
    • A. 

      Less than

    • B. 

      Equal

    • C. 

      Greter than

    • D. 

      Compilation error

  • 4. 
    What will be output if you will compile and execute the following c code? main() { float me = 1.1; double you = 1.1; if(me==you) printf("I love U"); else printf("I hate U"); }
    • A. 

      I love U

    • B. 

      I hate U

    • C. 

      Compiler Error

    • D. 

      None of These

  • 5. 
    What will be output if you will compile and execute the following c code? main() { static int var = 5; printf("%d ",var--); if(var) main(); }
    • A. 

      4 3 2 1

    • B. 

      Compilation Error

    • C. 

      5 4 3 2 1

    • D. 

      5 4 3 2

  • 6. 
    What will be output if you will compile and execute the following c code? main() { int i=1; while (i2) goto here; i++; }} fun() { here: printf("PP"); }
    • A. 

      1

    • B. 

      Pp

    • C. 

      Compiler Error

    • D. 

      None of These

  • 7. 
    What will be output if you will compile and execute the following c code? #define FALSE -1 #define TRUE 1 #define NULL 0 main() { if(NULL) puts("NULL"); else if(FALSE) puts("TRUE"); else puts("FALSE"); }
    • A. 

      1

    • B. 

      Linter Error

    • C. 

      Compiler Error

  • 8. 
    What will be output if you will compile and execute the following c code? #include int x; void main() { if (x) printf("hi"); else printf("how are u"); }
    • A. 

      Hi

    • B. 

      How are you

    • C. 

      Compile Time Error

    • D. 

      None of These

  • 9. 
    Predict the output/error. main() { int a = 4, b = 4; switch(a) { case 3 : printf(“\n a is 3”); break; case b : printf(“\n a is 4”); // case b : is not possible break; // because constant is needed default : printf(“\n a is not 3 or 4”); } return 0; }
    • A. 

      Compilation error

    • B. 

      A is 4

    • C. 

      A is not 3 or 4

    • D. 

      A id 3

  • 10. 
    The output of the code below is(when 1 is entered) #include void main() { double ch; printf("enter a value btw 1 to 2:"); scanf("%lf", &ch); switch (ch) // ch is declared as duble, but switch will accept { // always an integral value case 1: printf("1"); break; case 2: printf("2"); break; } }
    • A. 

      Compile time error

    • B. 

      1

    • C. 

      2

    • D. 

      No output

  • 11. 
    What will be output if you will compile and execute the following c code? void main() { int a=2; if(a==2) { a=~a+2
    • A. 

      It will print nothing

    • B. 

      -3

    • C. 

      -2

    • D. 

      1

  • 12. 
    The output of the following code will be main() { int y; scanf("%d",&y); // input given is 2000 if( (y%4==0 && y%100 != 0) || y%100 == 0 ) printf("%d is a leap year"); else printf("%d is not a leap year"); }
    • A. 

      2000 is a leap year

    • B. 

      2000 is not a leap year

    • C. 

      Compiler error

  • 13. 
    The output of the following code will be main() { char c=' ', x, convert(z); getc(c); if((c>='a') && (c
    • A. 

      Garbage value

    • B. 

      32

    • C. 

      Compiler error

    • D. 

      ‘z’

  • 14. 
    The output of the following code will be main() { int i =0;j=0; if(i && j++) printf("%d..%d",i++,j); printf("%d..%d,i,j); }
    • A. 

      1 0

    • B. 

      0..0

    • C. 

      1..1

    • D. 

      0..1

  • 15. 
    The output of the following code will be main() { int a= 0;int b = 20;char x =1;char y =10; if(a,b,x,y) printf("hello"); }
    • A. 

      Hello

    • B. 

      Compiler error

    • C. 

      20

    • D. 

      10

  • 16. 
    The output of the following code will be void main() { static int i=5; if(--i){ main(); printf("%d ",i); }
    • A. 

      5

    • B. 

      -4 -4 -4

    • C. 

      0 0 0 0

    • D. 

      3 3 3

  • 17. 
    The output of the following code will be void main() { int i; char a[]="\0"; if(printf("%s\n",a)) printf("Ok here \n"); else printf("Forget it\n"); }
    • A. 

      OK here

    • B. 

      Compiler error

    • C. 

      Forget

    • D. 

      Print nothing

  • 18. 
    The output of the following code will be void main() { while(1){ if(printf("%d",printf("%d"))) break; else continue; }
    • A. 

      Garbage value

    • B. 

      Compiler error

    • C. 

      % d

    • D. 

      Print nothing

  • 19. 
    The output of the following code will be #include main() { int x,y=2,z,a; if(x=y%2) z=2; a=2; printf("%d %d ",z,x); }
    • A. 

      2 2

    • B. 

      50 50

    • C. 

      0 0

    • D. 

      Garbage 0

  • 20. 
    The output of the following code will be main() { int i=10,j=20; j = i, j?(i,j)?i:j:j; printf("%d %d",i,j); }
    • A. 

      20 20

    • B. 

      10 10

    • C. 

      0 0

    • D. 

      Garbage values

Back to Top Back to top