1.
Which of the following is not a valid variable name declaration?
int _a3;
int a_3;
int 3_a;
int _3a;
2.
Which of the following is true for variable names in C?
They can contain alphanumeric characters as well as special characters
It is not an error to declare a variable to be one of the keywords(like goto, static)
Variable names cannot start with a digit
Variable can be of any length
3.
Which is valid C expression?
int my_num = 100,000;
int my_num = 100000;
int my num = 1000;
int $my_num = 10000;
4.
What will be the output of the following C code?
#include
int main()
{
printf("Hello World! %d \n", x);
return 0;
}
Hello World! x;
Hello World! followed by a junk value
Compile time error
Hello World!
5.
What will be the output of the following C code?
#include
int main()
{
int y = 10000;
y = 34;
printf("Hello World! %d\n", y);
return 0;
}
Compile time error
Hello World! 34
Hello World! 1000
Hello World! followed by a junk value
6.
What will be the output of the following C code?
#include
int main()
{
int m = 3;
printf("%d", m);
return 0;
}
It will cause a compile-time error
It will cause a run-time error
It will run without any error and prints 3
It will experience infinite looping
7.
A ...... translates a high-level language program into a machine language.
translator
compiler
memory
code editor
8.
Which of the following functions is used to display information on the screen?
scanf
printf
placeholder
header
9.
Which of the following functions is used to get an input from a user?
scanf
printf
placeholder
header
10.
What will be the function prototype for the function below:
double mult(double a, double b){
return a * b;
}
mult(a,b);
double mult(a,b);
double mult(double, double);
double mult(double a, double b){}
11.
What will be the output of the following C code?
#include
void main()
{
int x = 5;
if (x < 1){
printf("hello");
}
if (x == 5){
printf("hi");
}else{
printf("no");
}
}
hi
hello
no
error
12.
What will be the output of the following C code?
#include
void main()
{
int x = 4;
if (x < 1){
printf("Hello");
}
}
Nothing
Run time error
Hello
Varies
13.
What will be the output of the following C code?
#include
void main()
{
int x = 0;
if (x < 1){
printf("Hello");
}
}
Hello
Run time error
Nothing
Varies
14.
What will be the appropriate data type for an input of 2.5?
int
float or double
char
none
15.
What will be the appropriate data type for an integer input value?
int
char
float
double
16.
What will be the appropriate data type for a single character input?
char
int
float
double
17.
Which of the following is a placeholder for the int data type?
%f
%c
%i
%d
18.
Which of the following is a placeholder for the char data type?
%c
%d
%lf
%f
19.
Which of the following is a placeholder for the double data type?
%lf
%c
%s
%d
20.
What will be the output of the following C code?
#include
#include
int main()
{
int i = 5%2;
printf("i = %d",i);
return 0;
}
i = 2.5
i = 1
1
2.5
21.
Which of the following is a logical OR operator?
&
&&
||
None of the above
22.
What will be the output of the following C code?
#include
#include
int main()
{
int i = 8;
switch(i%3){
case 0:
printf("Result: 0");
break;
case 1:
printf("Result: 1");
break;
case 2:
printf("Result: 2");
break;
case 3:
printf("Result: 3");
break;
default:
printf("None");
}
return 0;
}
Result 0
Result 1
Result 2
Result 3
23.
What will be the output of the following C code?
#include
#include
int main()
{
int i = 8;
do{
printf("%d\n",i);
i++;
}while(i<5);
return 0;
}
Nothing
8
1
2
3
4
8
7
6
24.
What will be the output of the following C code?
#include
#include
int main()
{
int i = 8;
while(i<5){
printf("%d\n",i);
i++;
}
return 0;
}
8
1
2
3
4
8
7
6
Nothing
25.
Which of the following is not a loop?
for
while
do while
switch
26.
What will be the output of the following C code?
#include
#include
int main()
{
int i = 8;
i++;
printf("%d\n",i);
return 0;
}
8
7
9
6
27.
What will be the output of the following C code?
#include
#include
int main()
{
int i = 8;
i--;
printf("%d\n",i);
return 0;
}
8
9
7
6
28.
What will be the output of the following C code?
#include
#include
int main()
{
int a = 3;
int i;
for(i=0;i<5;i++){
printf("%d ",i*a);
}
return 0;
}
0 1 2 3 4
0 3 6 9 12
3
Nothing
29.
What will be the output of the following C code?
#include
#include
int main()
{
int i;
for(i=0;i<5;i++){
printf("*");
}
return 0;
}
*
**
***
*****
30.
Which of the following is a logical AND operator?
&
&&
||
None of the above