C And C Sharp Quizes

25 Questions | Attempts: 1029
Share

SettingsSettingsSettings
C And C Sharp Quizes - Quiz


Questions and Answers
  • 1. 
     Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?
    • A. 

      Rem = 3.14 % 2.1;

    • B. 

      Rem = modf(3.14, 2.1);

    • C. 

      Rem = fmod(3.14, 2.1);

    • D. 

      Remainder cannot be obtain in floating point division.

  • 2. 
    Point out the error in the following program     #include<stdio.h> int main() { display(); return 0; } void display() { printf("Welcome To Tait"); }
    • A. 

      No error

    • B. 

      Display() doesn't get invoked

    • C. 

      Display() is called before it is defined

    • D. 

      None of these

  • 3. 
     Which statement will you add in the following program to work it correctly?      #include<stdio.h> int main() { printf("%f\n", log(36.0)); return 0; }
    • A. 

      #include(conio.h)

    • B. 

      #include(math.h)

    • C. 

      #include(stdlib.h)

    • D. 

      #include(string.h)

  • 4. 
     In which header file is the NULL macro defined?
    • A. 

      Stdio.h

    • B. 

      Stddef.h

    • C. 

      Stdio.h and stddef.h

    • D. 

      Math.h

  • 5. 
    Point out the error in the program  #include<stdio.h> int main() { int a[] = {10, 20, 30, 40, 50}; int j; for(j=0; j<5; j++) { printf("%d\n", a); a++; } return 0; }
    • A. 

      Error: Declaration syntax

    • B. 

      Error: Expression syntax

    • C. 

      Error: LValue required

    • D. 

      Rvalue required

  • 6. 
    Which bitwise operator is suitable for checking whether a particular bit is on or off?
    • A. 

      && operator

    • B. 

      & operator

    • C. 

      || operator

    • D. 

      ! operator

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

      Ffff

    • B. 

      0fff

    • C. 

      000f

    • D. 

      Fff0

  • 8. 
    What function should be used to free the memory allocated by calloc() ?
    • A. 

      Dealloc();

    • B. 

      Malloc(variable_name, 0)

    • C. 

      Free();

    • D. 

      Memalloc(variable_name, 0)

  • 9. 
    What will be the output of the program?     #include #include int main() { char *s; char *fun(); s = fun(); printf("%s\n", s); return 0; } char *fun() { char buffer[30]; strcpy(buffer, "RAM"); return (buffer); }
    • A. 

      0xffff

    • B. 

      Garbage value

    • C. 

      Ram

    • D. 

      Error

  • 10. 
    Which standard library function will you use to find the last occurance of a character in a string in C?
    • A. 

      Strnchar()

    • B. 

      Strchar()

    • C. 

      Strrchar()

    • D. 

      Strrchr()

  • 11. 
    How many times the program will print "vardhaman" ?  #include<stdio.h> int main() { printf("vardhaman"); main(); return 0; }
    • A. 

      Infinite times

    • B. 

      32767 times

    • C. 

      65535 times

    • D. 

      Till stack overflows

  • 12. 
    Which of the following statements are correct about the program? #include<stdio.h> int main() { printf("%d\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

  • 13. 
    What does the following declaration mean?int (*ptr)[10];
    • A. 

      Ptr is array of pointers to 10 integers

    • B. 

      Ptr is a pointer to an array of 10 integers

    • C. 

      Ptr is an array of 10 integers

    • D. 

      Ptr is an pointer to array

  • 14. 
    What will be the output of the program ? #include<stdio.h> void fun(int **p); int main() { int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 8, 7, 8, 9, 0}; int *ptr; ptr = &a[0][0]; fun(&ptr); return 0; } void fun(int **p) { printf("%d\n", **p); }
    • A. 

      1

    • B. 

      2

    • C. 

      3

    • D. 

      4

  • 15. 
    What will be the output of the program ? #include<stdio.h> int main() { float arr[] = {12.4, 2.3, 4.5, 6.7,11.2}; printf("%d\n", sizeof(arr)/sizeof(arr[0])); return 0; }
    • A. 

      6

    • B. 

      4

    • C. 

      5

    • D. 

      7

  • 16. 
    What does fp point to in the program ? #include<stdio.h> int main() { FILE *fp; fp=fopen("trial", "r"); return 0; }
    • A. 

      The first character in the file

    • B. 

      A structure which contains a char pointer which points to the first character of a file.

    • C. 

      The name of the file.

    • D. 

      The last character in the file.

  • 17. 
    Which of the following are unary operators in C?1. !2. sizeof3. ~4. &&
    • A. 

      1,2

    • B. 

      1,3

    • C. 

      2,4

    • D. 

      1,2,3

  • 18. 
    What will be the output of the program? #include<stdio.h> int main() { int i=-3, j=2, k=0, m; m = ++i || ++j && ++k; printf("%d, %d, %d, %d\n", i, j, k, m); return 0; }
    • A. 

      2, 2, 0, 1

    • B. 

      1, 2, 1, 0

    • C. 

      -2, 2, 0, 0

    • D. 

      -2, 2, 0, 1

  • 19. 
    What will be the output of the program ? #include<stdio.h> #include<string.h> int main() { char str1[20] = "Hello", str2[20] = " World"; printf("%s\n", strcpy(str2, strcat(str1, str2))); return 0; }
    • A. 

      Hello

    • B. 

      World

    • C. 

      Hello World

    • D. 

      WorldHello

  • 20. 
    What do the 'c' and 'v' in argv stands for?
    • A. 

      'c' means argument control 'v' means argument vector

    • B. 

      'c' means argument count 'v' means argument vertex

    • C. 

      'c' means argument count 'v' means argument vector

    • D. 

      'c' means argument configuration 'v' means argument visibility

  • 21. 
    What will the SWAP macro in the following program be expanded to on preprocessing? will the code compile? #include<stdio.h> #define SWAP(a, b, c)(c t; t=a, a=b, b=t) int main() { int x=10, y=20; SWAP(x, y, int); printf("%d %d\n", x, y); return 0; }
    • A. 

      It compiles

    • B. 

      Compiles with an warning

    • C. 

      Not compile

    • D. 

      Compiles and print nothing

  • 22. 
    Which header file should be included to use functions like malloc() and calloc()?
    • A. 

      Memory.h

    • B. 

      Stdlib.h

    • C. 

      Math.h

    • D. 

      Dos.h

  • 23. 
    Which of the following is the correct usage of conditional operators used in C?
    • A. 

      A>b ? c=30 : c=40;

    • B. 

      A>b ? c=30;

    • C. 

      Max = a>b ? a>c?a:c:b>c?b:c

    • D. 

      Return (a>b)?(a:b)

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

      Switch

    • B. 

      Goto

    • C. 

      Go back

    • D. 

      Return

  • 25. 
    In which numbering system can the binary number 1011011111000101 be easily converted to?
    • A. 

      Decimal system

    • B. 

      Hexadecimal system

    • C. 

      Octal system

    • D. 

      No need to convert

Back to Top Back to top
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.