C Programming Skills Test! Trivia Quiz

40 Questions | Total Attempts: 91

SettingsSettingsSettings
C Programming Skills Test! Trivia Quiz - Quiz

.


Questions and Answers
  • 1. 
    Can we write a function that takes a variable argument list and passes the list to another function?
    • A. 

      True

    • B. 

      False

  • 2. 
    What will be the output of the program in Turbo C? #include int main() { char str[10] = "Choice"; str[6] = "User"; printf("%s\n", str); return 0; }
    • A. 

      Choice User

    • B. 

      Choice

    • C. 

      User

    • D. 

      Error

  • 3. 
    What will be the output of the program ? #include int main() { int i; char a[] = "\0"; if(printf("%s", a)) printf("The string is empty\n"); else printf("The string is not empty\n"); return 0; }
    • A. 

      The string is empty

    • B. 

      The string is not empty

    • C. 

      No output

    • D. 

      0

  • 4. 
    If the size of pointer is 32 bits What will be the output of the program ? #include int main() { char a[] = "Visual C++"; char *b = "Visual C++"; printf("%d, %d\n", sizeof(a), sizeof(b)); printf("%d, %d", sizeof(*a), sizeof(*b)); return 0; }
    • A. 

      10, 2 2, 2

    • B. 

      10, 4 1, 2

    • C. 

      11, 4 1, 1

    • D. 

      12, 2 2, 2

  • 5. 
    What will be the output of the program? #include #include int main() { char dest[] = {97, 97, 0}; char src[] = "aaa"; int i; if((i = memcmp(dest, src, 2))==0) printf("Got it"); else printf("Missed"); return 0; }
    • A. 

      Missed

    • B. 

      Got it

    • C. 

      Error in memcmp statement

    • D. 

      None of the above

  • 6. 
    What will be the output of the program (sample.c) given below if it is executed from the command line? cmd> sample Jan Feb Mar /* sample.c */ #include #include int main(int arc, char *arv[]) { int i; for(i=1; i<_argc; i++) printf("%s ", _argv[i]); return 0;
    • A. 

      No output

    • B. 

      Sample Jan Feb Mar

    • C. 

      Jan Feb Mar

    • D. 

      Error

  • 7. 
    What will be the output of the program (sample.c) given below if it is executed from the command line? cmd> sample one two three /* sample.c */ #include int main(int argc, char *argv[]) { int i=0; i+=strlen(argv[1]); while(i>0) { printf("%c", argv[1][--i]); } return 0; }
    • A. 

      Three two one

    • B. 

      Owt

    • C. 

      Eno

    • D. 

      Eerht

  • 8. 
    What will be the output of the program #include void fun(int); int main(int argc) { printf("%d\n", argc); fun(argc); return 0; } void fun(int i) { if(i!=4) main(++i); }
    • A. 

      123

    • B. 

      1234

    • C. 

      234

    • D. 

      1

  • 9. 
    What is the output of the program #include int main() { int x = 10, y = 20, z = 5, i; i = x < y < z; printf("%d\n", i); return 0; }
    • A. 

      0

    • B. 

      1

    • C. 

      Error

    • D. 

      None

  • 10. 
    What is the output of the program given below ? #include int main() { enum status { pass, fail, atkt}; enum status stud1, stud2, stud3; stud1 = pass; stud2 = atkt; stud3 = fail; printf("%d, %d, %d\n", stud1, stud2, stud3); return 0; }
    • A. 

      0, 1, 2

    • B. 

      0,2,1

    • C. 

      1, 2, 3

    • D. 

      1,3,2

  • 11. 
    Which files will get closed through the fclose() in the following program? #include int main() { FILE *fs, *ft, *fp; fp = fopen("A.C", "r"); fs = fopen("B.C", "r"); ft = fopen("C.C", "r"); fclose(fp, fs, ft); return 0; }
    • A. 

      "A.C" "B.C" "C.C"

    • B. 

      "B.C" "C.C"

    • C. 

      "A.C"

    • D. 

      Error in fclose()

  • 12. 
          Assunming, integer is 2 byte, What will be the output of the program? #include int main() { printf("%x\n", -2<<2); return 0; }
    • A. 

      Ffff

    • B. 

      0

    • C. 

      Fff8

    • D. 

      Error

  • 13. 
    What will be the output of the program? #include int main() { int fun(int); int i = fun(10); printf("%d\n", --i); return 0; } int fun(int i) { return (i++); }
    • A. 

      9

    • B. 

      10

    • C. 

      11

    • D. 

      8

  • 14. 
    What will be the output of the program in 16 bit platform (Turbo C under DOS) ? #include int main() { struct value { int bit1:1; int bit3:4; int bit4:4; }bit; printf("%d\n", sizeof(bit)); return 0; }
    • A. 

      1

    • B. 

      2

    • C. 

      4

    • D. 

      9

  • 15. 
    What will be the output of the program? #include int addmult(int ii, int jj) { int kk, ll; kk = ii + jj; ll = ii * jj; return (kk, ll); } int main() { int i=3, j=4, k, l; k = addmult(i, j); l = addmult(i, j); printf("%d %d\n", k, l); return 0; }
    • A. 

      12,12

    • B. 

      No error,no output

    • C. 

      Error: Compile error

    • D. 

      None

  • 16. 
    In the following program where is the variable a getting defined and where it is getting declared? #include int main() { extern int a; printf("%d\n", a); return 0; } int a=20;
    • A. 

      Extern int a is declaration, int a = 20 is the definition

    • B. 

      Int a = 20 is declaration, extern int a is the definition

    • C. 

      Int a = 20 is definition, a is not defined

    • D. 

      A is declared, a is not defined

  • 17. 
    What are the types of linkages?
    • A. 

      Internal and External

    • B. 

      External, Internal and None

    • C. 

      External and None

    • D. 

      None

  • 18. 
    Which of the following statements are correct about the program? #include int main() { printf("%p\n", main()); return 0; }
    • A. 

      It prints garbage values infinitely

    • B. 

      Runs infinitely without printing anything

    • C. 

      Error: main() cannot be called inside printf()

    • D. 

      No Error and print nothing

  • 19. 
    We want to round off x, a float, to an int value, The correct way to do is
    • A. 

      y = (int)(x + 0.5)

    • B. 

      Y = int(x + 0.5)

    • C. 

      y = (int)x + 0.5

    • D. 

      Y = (int)((int)x + 0.5)

  • 20. 
    Which of the following statements are correct about the below C-program? #include int main() { int x = 10, y = 100%90, i; for(i=1; i<10; i++) if(x != y); printf("x = %d y = %d\n", x, y); return 0; } 1 : The printf() function is called 10 times. 2 : The program will produce the output x = 10 y = 10 3 : The ; after the if(x!=y) will NOT produce an error. 4 : The program will not produce output.
    • A. 

      1

    • B. 

      2,3

    • C. 

      3,4

    • D. 

      4

  • 21. 
    What will be the output of the program? #include int main() { int k, num=30; k = (num>5 ? (num <=10 ? 100 : 200): 500); printf("%d\n", num); return 0; }
    • A. 

      200

    • B. 

      30

    • C. 

      100

    • D. 

      400

  • 22. 
    Point out the error in the following program. #include int main() { struct emp { char name[20]; float sal; }; struct emp e[10]; int i; for(i=0; i<=9; i++) scanf("%s %f", e[i].name, &e[i].sal); return 0; }
    • A. 

      Suspicious pointer conversion

    • B. 

      Floating point formats not linked (Run time error)

    • C. 

      Cannot use scanf() for structures

    • D. 

      Strings cannot be nested inside structures

  • 23. 
    The keyword used to transfer control from a function back to the calling function is
    • A. 

      Switch

    • B. 

      Goto

    • C. 

      Go back

    • D. 

      Return

  • 24. 
    Which of the following statements are correct about the function? long fun(int num) { int i; long f=1; for(i=1; i<=num; i++) f = f * i; return f; }
    • A. 

      The function calculates the value of 1 raised to power num.

    • B. 

      The function calculates the square root of an integer

    • C. 

      The function calculates the factorial value of an integer

    • D. 

      None of above

  • 25. 
    Which of the statements is correct about the program? #include int main() { float a=3.14; char *j; j = (char*)&a; printf("%d\n", *j); return 0; }
    • A. 

      It prints ASCII value of the binary number present in the first byte of a float variable a.

    • B. 

      It prints character equivalent of the binary number present in the first byte of a float variable a.

    • C. 

      It will print 3

    • D. 

      It will print a garbage value

Back to Top Back to top