Quiz: C Programming Structure And Pointer! Trivia Questions Test

15 Questions | Total Attempts: 105

SettingsSettingsSettings
Please wait...
Quiz: C Programming Structure And Pointer! Trivia Questions Test

C programming is one of the most popular programming languages, and over the week we got to cover much about C programming structure and pointers. Do you recall that a pointer is a variable which points to the address of another variable of any data type? Take up this test and get to see how much you recall from class.


Questions and Answers
  • 1. 
    If a variable is a pointer to a structure, then which of the following operator is used to access data members of the structure through the pointer variable?
    • A. 

      '.'

    • B. 

      '&'

    • C. 

      '*'

    • D. 

      '->'

  • 2. 
    What will be the output of the program ?   int main() {     inti=3, *j, k;     j = &i;     printf("%d\n", i**j*i+*j);     return0; }
    • A. 

      30

    • B. 

      27

    • C. 

      9

    • D. 

      3

  • 3. 
    What will be the output of the program?   int main() {     void *vp;     char ch=74, *cp="JACK";     int j=65;     vp=&ch;     printf("%c", *(char*)vp);     vp=&j;     printf("%c", *(int*)vp);     vp=cp;     printf("%s", (char*)vp+2);     return 0; }
    • A. 

      JACK

    • B. 

      JCK

    • C. 

      J65K

    • D. 

      JAK

  • 4. 
    What will be the output of the program ? int main() {     inti, a[] = {2, 4, 6, 8, 10};     change(a, 5);     for(i=0; i<=4; i++)         printf("%d, ", a[i]);     return 0; } change(int *b, int n) {     int i;     for(i=0; i<n; i++)         *(b+1) = *(b+i)+5; }
    • A. 

      7, 9, 11, 13, 15

    • B. 

      2, 4, 6, 8, 10

    • C. 

      3, 1, -1, -3, -5

    • D. 

      2, 15, 6, 8, 10

  • 5. 
    What will be the output of the program ? int main() { char *str; str = "%s"; printf(str, "K\n"); return 0; }
    • A. 

      Error

    • B. 

      K

    • C. 

      No Output

    • D. 

      %s

  • 6. 
    Which of the following function is used to find the first occurrence of a given string in another string?
    • A. 

      Strchr()

    • B. 

      Strrchr()

    • C. 

      Strstr()

    • D. 

      Strnset()

  • 7. 
    What will be the output of the program ?   int main() {     char p[] = "%d\n";     p[1] = 'c';     printf(p, 65);     return 0; }
    • A. 

      A

    • B. 

      A

    • C. 

      65

    • D. 

      C

  • 8. 
    Trace the output. int main() {     char str[] = "basic";     char *s = str;     printf("%s ", s++ +3);     printf("%s",s);     return 0; }
    • A. 

      C c

    • B. 

      Ic asic

    • C. 

      Asic sic

    • D. 

      C basic

  • 9. 
    What would be the equivalent pointer expression for referring the array element a[i][j][k][l]
    • A. 

      ((((a+i)+j)+k)+l)

    • B. 

      (((a+i)+j)+k+l)

    • C. 

      *(*(*(*(a+i)+j)+k)+l)

    • D. 

      *((a+i)+j+k+l)

  • 10. 
    What will be the output of the program ?   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

  • 11. 
    Are the expression *ptr++ and ++*ptr are same?
    • A. 

      True

    • B. 

      False

  • 12. 
    If the size of integer is 4bytes, What will be the output of the program? int main() { int arr[] = {12, 13, 14, 15, 16}; printf("%d, %d, %d\n", sizeof(arr), sizeof(*arr), sizeof(arr[0])); return 0; }
    • A. 

      10, 2, 4

    • B. 

      20, 2, 2

    • C. 

      20, 4, 4

    • D. 

      16, 2, 2

  • 13. 
    What will be the output of the program ? int main() {     char str[] = "India\0\is Best\0";     printf("%d\n", strlen(str));     return 0; }
    • A. 

      10

    • B. 

      6

    • C. 

      5

    • D. 

      11

  • 14. 
    What will be the output of the program ? int main() {     printf(5+"Good Morning\n");   return 0; }
    • A. 

      M

    • B. 

      Morning

    • C. 

      Good Morning

    • D. 

      Good

  • 15. 
    What will be the output of the program ? int main() {     char str1[] = "Hello";     char str2[] = "Hello";     if(str1 == str2)         printf("Equal\n");     else         printf("Unequal\n");     return 0; }
    • A. 

      Equal

    • B. 

      Error

    • C. 

      Unequal

    • D. 

      None of above