WorksheetsOPERATORS QUIZ C
Total questions: 62
Worksheet time: 31mins
Which of the following is the correct structure of a C program?
Documentation, Linking, Definition, Global Declaration, Main Function, Sub Programs
Documentation, Definition, Linking, Global Declaration, Main Function, Sub Programs
Documentation, Linking, Definition, Global Declaration, Sub Programs, Main Function
Definition, Documentation, Linking, Global Declaration, Main Function, Sub Programs
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
How would you print a string in C?
printf("%d", str);
printf("%c", str);
printf("%s", str);
printf("%f", str);
Which of the following code snippets contains a valid identifier?
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?
The code correctly uses a keyword.
The code does not correctly use a keyword.
What will be the output of the following C program?
error
10
default value
nothing will be printed
What will be the output of the following C program?
Value = 5.2
Value = 5.25
Value = 5
Value = 5.250000
What will be the output of the following C program?
Enter your name: Hello, [input]
Enter your name: [input] Hello,
Hello, [input]
The code will produce a compilation error.
What will be the output of the following C program?
a = 10, b = 20
a = 20, b = 10
a = 1020, b = 2010
The code will produce a compilation error.
What will be the output of the following C program?
a = 5, b = 5.5
a = 5, b = 5
a = 5, b = 5.50
The code will produce a compilation error.
What will be the output of the following C program?
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?
10
0
Garbage value
Compilation error
What will be the output of the following C program?
5 5
6 5
5 6
6 6
What will be the output of the following C program?
16
13
11
10
What will be the output of the following C program?
0
1
3
5
What will be the output of the following C program?
0
1
3
5
What will be the output of the following C program?
1
3
5
7
What will be the output of the following C program?
5
10
0
15
What will be the output of the following C program?
10
0
Garbage value
Compilation error
What will be the output of the following C program?
#include
10
Address of a
Garbage value
0
What will be the output of the following C program?
#include
10
12
15
20
What will be the output of the following C program?
#include
10
20
30
0
#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 will be the value of x after executing the following code?
#include
11
13
16
10
What is the output of the following code?
#include
0
1
-1
10
What will be the output of the following code?
#include
1
3
10
0
Which operator is used to perform bitwise OR in C?
|
||
&
&&
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 be the value of b after the following code is executed? int a = 10.5; int b = a;
10
10.5
Undefined
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
When a double value is converted to an int, what happens to the fractional part?
It is rounded to the nearest integer
It is truncated
It causes a compilation error
It remains as is
What will be the output of the following code? int a = 5, b = 2; float c = (float)a / b;
2.5
2.0
2
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 output of the following code? char a = 100; int b = 50000; long c = a + b; printf("%ld", c);
50100
50100L
50100.0
Compilation error
Given the following code, what is the value of result? short a = 5; float b = 3.2; double result = a * b;
16
16.0
16.0f
Compilation error
What is the output of the following code? unsigned int a = 3; int b = -4; printf("%u", a + b);
-1
4294967295
4294967299
Compilation error
Determine the output: int a = 2147483647; unsigned int b = 1; printf("%d", a + b);
-2147483648
2147483648
0
Compilation error
What is the value of x after this code executes? double x = 10.75; int y = x; x = y;
10
10.75
11
Undefined
What is the output of the following code? float a = 3.14; int b = a; printf("%d", b);
3
3.14
4
Compilation error
What will be the value of y after the execution of this code? unsigned char x = 255; int y = x;
255
-1
255U
Compilation error
What will be the value of b after the following code is executed? double a = 5.5; int b = (int)a;
5
5.5
6
Undefined
What is the value of b after the following code is executed? double a = 12.999; int b = (int)a;
12
13
12.999
Compilation error
What is the output of this code? float a = 4.75; int b = a; printf("%d", b);
4
5
4.75
Compilation error
What is the output of the following code? double a = 2.71828; int b = (int)a; printf("%d", b);
2
3
2.71828
Compilation error
What will be the result of this code? double x = -7.999; int y = (int)x;
-8
-7
-7.999
Compilation error
What is the result of this code? int a = 7; int b = 3; float c = (float)a / b;
2.333333
2
2.0
Compilation error
