C Language Exam 1

40 Questions  I  By Sudha_test
Please take the quiz to rate it.

C Programming Quizzes & Trivia
This is a sample C test

  
Changes are done, please start the quiz.


Questions and Answers

Removing question excerpt is a premium feature

Upgrade and get a lot more done!
  • 1. 
    Identify the loop construct:
    • A. 

      If-else

    • B. 

      Goto

    • C. 

      While

    • D. 

      Switch-case


  • 2. 
    Which of the following is not a storage class
    • A. 

      External

    • B. 

      Automatic

    • C. 

      Register

    • D. 

      Define


  • 3. 
    Which of the following is a correct way of defining a symbolic constant pie in C
    • A. 

      # define pie = 22/7

    • B. 

      #define pie 22/7

    • C. 

      #define pie= 3.142

    • D. 

      # Define pie 22/7


  • 4. 
    The minimum number of times the for loop is executed is
    • A. 

      0

    • B. 

      Cannot be predicted

    • C. 

      1

    • D. 

      2


  • 5. 
    In switch statement
    • A. 

      More than one default allowesd

    • B. 

      Default case, if used, should be the last case

    • C. 

      Default case, if used, can be placed anywhere

    • D. 

      Default case must be present


  • 6. 
    How many while statements are possible in do.... While loop?
    • A. 

      2

    • B. 

      3

    • C. 

      Any number

    • D. 

      1


  • 7. 
    The storage area for register variables
    • A. 

      Cache

    • B. 

      Memory

    • C. 

      Processor registers

    • D. 

      Virtual memory


  • 8. 
    Which of the following statements is false
    • A. 

      The initialization and increment parts of a for statement can be empty

    • B. 

      The body of do-while statement can be empty

    • C. 

      The expression in the condition part of a for statement can be empty

    • D. 

      The initialization part of a for statement cannot have more than one initialization


  • 9. 
    Consider the segment If(1) printf(“yes”); else printf(“no”); what will be the output
    • A. 

      No

    • B. 

      Unpredictable

    • C. 

      Yes

    • D. 

      Error


  • 10. 
    The global variable can be declared
    • A. 

      After main

    • B. 

      After block

    • C. 

      Before main

    • D. 

      Within block


  • 11. 
    Which of the following is not correct
    • A. 

      While loop is executed atleast once

    • B. 

      Do . while loop is executed at least once

    • C. 

      While loop is executed only if the condition is true

    • D. 

      Dowhile loop is ececuted only if the condition is true


  • 12. 
    printf (“\ “ well done\” ”); what will be the output of this statement
    • A. 

      \“well done \”

    • B. 

      Well done

    • C. 

      “ well done”

    • D. 

      \ well done \


  • 13. 
    What is the output of the following program main() {static int y; printf (“%d\n”, y); }
    • A. 

      0

    • B. 

      Run-time error

    • C. 

      Undefined

    • D. 

      Compilation error


  • 14. 
    The number of elements in array declaration
    • A. 

      Dynamically identifies based on largest index used in program

    • B. 

      Does not require to be specified

    • C. 

      Assume default size as ‘0’

    • D. 

      Requires to be specified


  • 15. 
    In C every variable has
    • A. 

      A type and size

    • B. 

      A type, name, value and size

    • C. 

      A name and type

    • D. 

      A size and value


  • 16. 
    All the elements in the array must be
    • A. 

      Defined

    • B. 

      Neither initialized nor defined

    • C. 

      Initialized and defined

    • D. 

      Initialized


  • 17. 
    How many bytes will be allotted for the declaration int num[4] [3]
    • A. 

      6 bytes

    • B. 

      24 bytes

    • C. 

      12 bytes

    • D. 

      48 bytes


  • 18. 
    If statement is a —————statement
    • A. 

      Loop construct

    • B. 

      Two way decision

    • C. 

      Multiway decision

    • D. 

      One-way decision


  • 19. 
    The total memory required for an array
    • A. 

      Sizeof (datatype) * 2

    • B. 

      Size of (datatype) * size of used array elements

    • C. 

      Sizeof (datatype) * sizeof array

    • D. 

      Size of (array) * datatype


  • 20. 
    int table [2][3] ={{0}, {0}} in this statement
    • A. 

      None of the element are initialized to zero

    • B. 

      Only first row elements are initialized to zero

    • C. 

      Only last row elements are initialized to zero

    • D. 

      All the array elements are initialized to zero


  • 21. 
    The statements that prints out the character set from A-Z is, where a is an integer variable
    • A. 

      For(a=‘A’; a<=‘z’, a++) printf(“%c”; a);

    • B. 

      For(a=‘A’; a<=‘z’, a++) printf(“%c”; a);

    • C. 

      For(a=‘a’; a<=‘z’, a++) printf(“%c”; a);

    • D. 

      For(a=’A’ a<=‘Z’, a++) printf(“%c”; a);


  • 22. 
    The amount of storage required for holding elements of the array depends on
    • A. 

      Data type

    • B. 

      Datatype and size

    • C. 

      Run-time requirement

    • D. 

      Size


  • 23. 
    If we don’t initialize a static array, what will be the elements set to:
    • A. 

      Character constant

    • B. 

      A floating point number

    • C. 

      0

    • D. 

      An undetermined value


  • 24. 
    What is wrong with the following program main() { char m1[9]= “message1”; char m2[9]=“message2”; m2=m1; printf(“msg is %s”,m2); }
    • A. 

      Char array cannot be printed directly using printf

    • B. 

      Array is not a left value and so cannot be assigned to

    • C. 

      Program compiles without error, but prints an unpredictable value

    • D. 

      Array cannot be initialized as above


  • 25. 
    Array subscripts in ‘C’ always start at
    • A. 

      0

    • B. 

      Compiler dependent

    • C. 

      1

    • D. 

      -1


  • 26. 
    The maximum number of dimension an array can have in C language is
    • A. 

      4

    • B. 

      5

    • C. 

      Compiler dependent

    • D. 

      3


  • 27. 
    What is the result of the expression ( 10/3 )*3+5%3 ?
    • A. 

      10

    • B. 

      11

    • C. 

      8

    • D. 

      1


  • 28. 
    Output of the below program #include<stdio.h> main() {int a,b=0; int c[10]={1,2,3,4,5,6,7,8,9,0 }; for(a=0;a<10;++a) b+=c[a]; printf(“%d”,b); }
    • A. 

      1 3 6 10 15 21 28 32 45 45

    • B. 

      55

    • C. 

      45

    • D. 

      0


  • 29. 
    consider the array definition int num [10] = { 3 ,3 ,3 }; pick the correct answers
    • A. 

      This is syntactically wrong

    • B. 

      The value of num[8] is 3

    • C. 

      This is invalid if it comes within a function

    • D. 

      The value of num[2] is 3


  • 30. 
    Which of the follwing is a string
    • A. 

      ‘abcd’

    • B. 

      “abcd”

    • C. 

      Abcd

    • D. 

      ‘abcd”


  • 31. 
    Give the output of the following program: #include < stdio.h > main() {int I=1; while (I < 5) {printf(“%d”, I); }} /* End of Main */
    • A. 

      Print the value of I as 1

    • B. 

      Warning for no return type for main ( )

    • C. 

      Infinite loop

    • D. 

      Prints the value of I as11111


  • 32. 
    How would you copy the name “Hello” to a character array (i.e. string) declared as char str[10];
    • A. 

      Strcpy( str, “Hello” );

    • B. 

      Strcat(str,“Hello”);

    • C. 

      Printf( str, “Hello” );

    • D. 

      Str = “Hello”;


  • 33. 
    count=0; for ( I=0;I<=10; I++) {if(I%2==0) count++; }printf(“%d”, count); Pick out the correct value for count
    • A. 

      6

    • B. 

      3

    • C. 

      4

    • D. 

      5


  • 34. 
    What will happen if you try to put so many values into an array during the initalization such that its size is  exceeded
    • A. 

      Error message from the compiler

    • B. 

      Possible system malfunction

    • C. 

      Last element data may be overwritten

    • D. 

      Nothing


  • 35. 
    Compute the result of the following expression in ‘C’. A=3*4/5+10/5+8-1+7/8
    • A. 

      11

    • B. 

      10

    • C. 

      12

    • D. 

      9


  • 36. 
    Which of the following statements would read a single character from the keyboard and place the result in a character variable ‘ch’ defined as: char ch;
    • A. 

      Ch = getch( );

    • B. 

      Printf( “%c”, ch );

    • C. 

      While(!kbhit)

    • D. 

      Getkeyb ( ch );


  • 37. 
    What is the output of the following module sum=0; I=0; do{ sum+=I; I++; }while(I<=5); printf(“%d”, sum);
    • A. 

      28

    • B. 

      10

    • C. 

      15

    • D. 

      21


  • 38. 
    The value within the [] brackets in an array declaration specifies
    • A. 

      Value of the array element

    • B. 

      Subscript value

    • C. 

      Address value

    • D. 

      Size of an array


  • 39. 
    Dynamic memory allocation in array results in
    • A. 

      Allocation of memory at debugging time

    • B. 

      Allocation of memory at file saving time

    • C. 

      Allocation of memory at compile time

    • D. 

      Allocation of memory at runtime


  • 40. 
    main() { char name[5]; scanf(“%s”,name); printf(“%s”, name); }if Program is the given as input, what will be the o/p of the program;
    • A. 

      Progr

    • B. 

      Prog

    • C. 

      Program

    • D. 

      Runtime error


Back to top

Removing ad is a premium feature

Upgrade and get a lot more done!
Take Another Quiz
We have sent an email with your new password.