C Programming Language Quiz 2
Tests fundamental C programming concepts including arrays, operators, variables, I/O, and control flow.
Questions
Question 1 Multiple Choice (Single Answer)
To declare and initialize character array :
- char s[] = { 'a', 'b' , 'c' };
- char s[] = "abc";
- both correct
- 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);
- 8
- 9
- 10
- 11
Question 3 Multiple Choice (Single Answer)
What is the role of variables in programming languages:
- Perform standard functions like printing to the screen
- Data storage
- Both correct
- Both wrong
Question 4 Multiple Choice (Single Answer)
what is the output of the following program
main(){
int x;
printf(“%d”,x);
}
- Unknown (random value)
- Zero
- 3000
- 4000
Question 5 Multiple Choice (Single Answer)
float values(200) = ( 1 , 2 , 3 , 4 );
- is correct
- has syntax error
- causes run-time error
- none of the above
Question 6 Multiple Choice (Single Answer)
To write statement hi world:
- puts('hi world');
- puts("hi world");
- Both correct
- Both wrong
Question 7 Multiple Choice (Single Answer)
The variables in C programming language:
- Must be declared before being used.
- Can be used without declaration
- Can be used before declaration
- none of the above
Question 8 Multiple Choice (Single Answer)
consider the following statement:
while ( 3 ) ;
- Infinite loop
- Syntax error
- Executes only 3 iterations
- Executes only 4 iterations
Question 9 Multiple Choice (Single Answer)
To include a header file in a C program:
- #include "stdio.h"
- #include <stdio.h>
- Both correct
- Both wrong
Question 10 Multiple Choice (Single Answer)
what is the best choice to print the value of variable x where:
int x = 123;
- printf("%f",x);
- printf("%d",x);
- printf("%c",x);
- printf("%s",x);