C Programming Language Quiz 2

Tests fundamental C programming concepts including arrays, operators, variables, I/O, and control flow.

10 Questions Published

Questions

Question 1 Multiple Choice (Single Answer)

To declare and initialize character array :

  1. char s[] = { 'a', 'b' , 'c' };
  2. char s[] = "abc";
  3. both correct
  4. both wrong
Question 2 Multiple Choice (Single Answer)

What is the output of the following piece of code?

int x = 3, y = 5, z ;
z = x++ + ++y;

printf(“%d”,z);

  1. 8
  2. 9
  3. 10
  4. 11
Question 3 Multiple Choice (Single Answer)

What is the role of variables in programming languages:

  1. Perform standard functions like printing to the screen
  2. Data storage
  3. Both correct
  4. Both wrong
Question 4 Multiple Choice (Single Answer)

what is the output of the following program

main(){
int x;
printf(“%d”,x);
}

  1. Unknown (random value)
  2. Zero
  3. 3000
  4. 4000
Question 5 Multiple Choice (Single Answer)

float values(200) = ( 1 , 2 , 3 , 4 );

  1. is correct
  2. has syntax error
  3. causes run-time error
  4. none of the above
Question 6 Multiple Choice (Single Answer)

To write statement hi world:

  1. puts('hi world');
  2. puts("hi world");
  3. Both correct
  4. Both wrong
Question 7 Multiple Choice (Single Answer)

The variables in C programming language:

  1. Must be declared before being used.
  2. Can be used without declaration
  3. Can be used before declaration
  4. none of the above
Question 8 Multiple Choice (Single Answer)

consider the following statement:

while ( 3 ) ;

  1. Infinite loop
  2. Syntax error
  3. Executes only 3 iterations
  4. Executes only 4 iterations
Question 9 Multiple Choice (Single Answer)

To include a header file in a C program:

  1. #include "stdio.h"
  2. #include <stdio.h>
  3. Both correct
  4. Both wrong
Question 10 Multiple Choice (Single Answer)

what is the best choice to print the value of variable x where:

int x = 123;

  1. printf("%f",x);
  2. printf("%d",x);
  3. printf("%c",x);
  4. printf("%s",x);