C Programming Basics: Quiz!

10 Questions | Total Attempts: 321

SettingsSettingsSettings
Please wait...
C Programming Basics: Quiz!

.


Questions and Answers
  • 1. 
    What is the right way to initialize an array?​
    • A. 

      Int num[6] = { 2, 4, 12, 5, 45, 5 };

    • B. 

      Int n{} = { 2, 4, 12, 5, 45, 5 };

    • C. 

      Int n{6} = { 2, 4, 12 };

    • D. 

      Int n(6) = { 2, 4, 12, 5, 45, 5 };

  • 2. 
    What will be the output of the program?#include<stdio.h>void main(){    int a[5] = {5, 1, 15, 20, 25};    int i, j, m;   i = ++a[1];   j = a[1]++;   m = a[i++];   printf("%d, %d, %d", i, j, m);} ​
    • A. 

      3, 2, 15

    • B. 

      2, 3, 20

    • C. 

      2, 1, 15

    • D. 

      1, 2, 5

  • 3. 
    What will be the output of following program code?#include <stdio.h>int main(void){    char p;   char buf[10] = {1, 2, 3, 4, 5, 6, 9, 8};   p = (buf + 1)[5];    printf("%d", p);   return 0;}
    • A. 

      5

    • B. 

      6

    • C. 

      9

    • D. 

      10

  • 4. 
    An array elements are always stored in ________ memory locations. 
    • A. 

      Sequential

    • B. 

      Random

    • C. 

      Sequential and Random

    • D. 

      None of the Above

  • 5. 
    Let x be an array. Which of the following operations are illegal?I.    ++xII.    x+1III.    x++IV.    x*2
    • A. 

      I and II

    • B. 

      I, II and III

    • C. 

      II and III

    • D. 

      I, III and IV

    • E. 

      III and IV

  • 6. 
    Size of the array need not be specified, when-
    • A. 

      Initialization is a part of definition

    • B. 

      It is a declaration

    • C. 

      It is a formal parameter

    • D. 

      All of these

  • 7. 
    Consider the following type definition.typedef char x[10];x myArray[5];What will sizeof(myArray) be ? (Assume one character occupies 1 byte)
    • A. 

      15

    • B. 

      10

    • C. 

      50

    • D. 

      30

    • E. 

      None of the above

  • 8. 
    What will be printed after execution of the following code?void main(){  int arr[10] = {1,2,3,4,5};      printf("%d", arr[5]);}
    • A. 

      Garbage Value

    • B. 

      5

    • C. 

      6

    • D. 

      0

    • E. 

      None of the above

  • 9. 
    What will be the output of the program if the array begins at 65472 and each integer occupies 2 bytes?#include<stdio.h>      void main(){    int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0}; printf("%u, %u", a+1, &a+1);}
    • A. 

      65474, 65488

    • B. 

      65480, 65488

    • C. 

      65480, 65496

    • D. 

      65474, 65476

  • 10. 
    What will happen after compiling and running following code?main(){     printf("%p", main);       }
    • A. 

      Error

    • B. 

      Some address will be printed.

    • C. 

      None of these

    • D. 

      Will make an infinite loop