Font size
WorksheetsC BASIC&OPERATORSQUIZFINAL
Total questions: 60
Worksheet time: 3600secs
What is the entry point of a C program?
start()
begin()
main()
program()
Which of the following is a valid identifier in C?
2variable
variable_name
var-name
var name
Which of the following is not a valid identifier?
myVar
_var123
123var
var_123
Which of the following is a keyword in C?
function
define
return
begin
Which of the following is the correct way to declare a variable in C?
int variable;
int variable:
int variable{};
int variable()
Which of the following is true about variables in C?
Variables can be declared without specifying a data type.
Variable names can start with a digit.
Variables can be declared anywhere in the program before they are used.
Variables do not need to be initialized before use.
Which of the following is not a basic data type in C?
int
float
double
string
Which of the following data types has the highest precision?
int
float
double
char
Which function is used to read formatted input from the standard input in C?
printf()
scanf()
gets()
puts()
Which of the following format specifiers is used to print a floating-point number?
%d
%c
%f
%s
Which of the following code snippets contains a valid identifier?
#include <stdio.h>
int main() {
int 1variable = 10;
printf("%d\n", 1variable);
return 0;
}
The code contains a valid identifier.
The code does not contain a valid identifier.
Which of the following code snippets correctly uses a keyword in C?
#include <stdio.h>
int main() {
int return = 10;
printf("%d\n", return);
return 0;
}
The code correctly uses a keyword.
The code does not correctly use a keyword.
What will be the output of the following C program?
#include <stdio.h>
int main() {
double num = 5.25;
printf("Value = %.2f\n", num);
return 0;
Value = 5.2
Value = 5.25
Value = 5
Value = 5.250000
What will be the output of the following C program?
#include <stdio.h>
int main() {
int a = 5;
float b = 5.5;
printf("a = %d, b = %.1f\n", a, b);
return 0;
}
a = 5, b = 5
a = 5, b = 5.5
a = 5, b = 5.50
The code will produce a compilation error.
What will be the output of the following C program?
#include <stdio.h>
int main() {
float a = 7.0;
int b = 2;
float result = a / b;
printf("Result = %.1f\n", result);
return 0;
}
Result = 3
Result = 3.5
Result = 3.0
The code will produce a compilation error.
What will be the output of the following C program?
#include <stdio.h>
int main() {
int a = 10;
int b = a;
printf("%d\n", b);
return 0;
}
10
0
Garbage value
Compilation error
What will be the output of the following C program?
int main() {
int a = 5, b = 3;
int result = a + b * 2;
printf("%d\n", result);
return 0;
}
16
13
11
10
What will be the output of the following C program?#include <stdio.h>
int main() {
int a = 5, b = 3;
int result = (a > b) && (a < 10);
printf("%d\n", result);
return 0;
}
0
1
3
5
#include
15
16
17
18
What is the output of the following code?
#include
2
2.33
3
3.5
What will be the output of the following code?
#include
0
1
5
-1
Which of the following is the correct order of precedence (from highest to lowest) of the given operators?
+, *, &&, ||
*, +, &&, ||
&&, ||, +, *
||, &&, +, *
What will be the output of the following code?
#include
1
2
3
5
What is the output of the following code?
#include
0
1
-1
10
What is the output of the following code?
#include
5
10
-5
0
What will be the result of the following expression in C? int a = 5; float b = 2.5; float c = a + b;
7.5
7
5.0
Compilation error
What happens when an int and a double are used together in an arithmetic expression?
The int is promoted to a double
The double is demoted to an int
The result is always an int
Compilation error
What will happen if we assign a float value to an int variable?
The value will be rounded off
The value will be truncated
The value will remain the same
Compilation error
What is the result of the following code? float a = 9.8; int b = (int)a;
9.8
10
9
Compilation error
What does the following expression evaluate to? int a = 7; int b = 2; double c = (double)(a / b);
3.5
3.0
3
Compilation error
What will be the result of this code? double x = -7.999; int y = (int)x;
-8
-7
-7.999
Compilation error
#include main() { int a=012,b=034; int x=0x12,y=0x34; int c,d,u,v; c=a&&b; d=a||b; u=x&&y; v=x||y; printf("%d%d%d%d",c,d,u,v); }
What will be the output of the following 'C' code? void main ( ) { int x = 128; printf ("\n%d", 1 + x ++); }
128
129
What will be the output of the following 'C' code? #include
0
1
What will be the output of the following 'C' code? #include
x=2 y=-16
x=-2 y=16
What will be the output of the following 'C' code? #include
x=16
x=4
What will be the output of the following 'C' code? #include
x=-1
x=1
What will be the output of the following 'C' code? #include
1, 1.000000
0, 0.000000
What will be the output of the following 'C' code? #include
7
1
What will be the output of the following 'C' code? #include
x= 0, y= 0
x= 1, y= 1
What will be the output of the following 'C' code? #include
ans= 1
ans= 0
What will be the output of the following 'C' code? #include
ans= 100
ans= 200
What will be the output of the following 'C' code? #include
ans= 1
ans= 0
What will be the output of the following 'C' code? #include
ans= 1
ans= 0
What will be the output of the following 'C' code? #include
10 20 30
10 20 0
What will be the output of the following 'C' code? #include
k= 200
k= 100
What will be the output of the following 'C' code? #include
ans= 30
ans= 20
What will be the output of the following 'C' code? #include
15
5
What will be the output of the following 'C' code? #include
9
6
#include main()
{ int i=10,j; j=++i++; printf("%d%d",i,j); }
#include main()
{ inti=10,j=11,k,l; k=i+++j; l=i+++++j; printf("%d%d",l,k); }
#include main()
{ int x=20,y=35; x=y++ + x++; y=++y + ++x; printf("%d%d",x,y); }
#include main()
{ int i=0,j=1,k=2,l; l=++i&&j++||++k; printf("%d %d %d %d",i,j,k,l); }
#include main()
{ float a=0.5; int c; c=a<0.5; printf("%d",c); }
#include main()
{ int a=0,b=0; ++a==0||++b==||; printf("%d%d",a,b); }
#include main()
{ int c=- -2; printf("%d",c); }
#include main()
{ int i=5; printf("%d%d%d%d%d",i++,i--,++i,--i,i); }
#include int main()
{ int a = 2,b = 5; a = a^b; b = b^a; printf("%d %d",a,b); return 0; }
#include int main()
{ int a = 2,b = 5; a = a^b; b = b^a; printf("%d %d",a,b); return 0; }
#include
