WorksheetsByteBattle2.0(C)
Total questions: 30
Worksheet time: 23mins
What is the extension of C programming files?
.txt
.c
.cpp
.java
Which function is used to display output in C?
print()
System.out.println()
cout
printf()
Which symbol is used to end a statement in C?
:
.
;
,
Which of the following is a valid variable declaration in C?
int 1num
int num1;
int #num;
int num ;
What is the correct syntax for a main function in C?
int main()
void main()
main()
public main()
What will the following code print? printf("Hello, World!");
Hello
World
Hello, World!
Error
Which of the following is a valid comment in C?
# This is a comment
// This is a comment
/* This is a comment */
Both b) and c)
What is the purpose of the return 0; statement in the main function?
To terminate the program
To indicate successful program completion
To print the value 0
To declare a variable
Which of the following is a valid if statement in C?
if (x = 10)
if (x == 10)
if x == 10:
if (x 10)
Which function is used to take input from the user in C?
printf()
scanf()
cin
gets()
What is the correct syntax to declare an integer variable in C?
int a;
integer a;
int a[];
int a(10);
What will the following code print? int a = 10; printf("%d", a);
10
0
a
Compilation error
Which of the following is not a valid C keyword?
int
float
char
string
What is the result of 5 + 2 * 3 in C?
21
11
16
7
Which operator is used to assign a value to a variable?
=
==
+=
&
What is the result of the following code? int a = 5; a++; printf("%d", a);
5
6
4
Compilation error
Which data type can store a decimal number?
int
char
float
void
Which of the following is a relational operator in C?
+
*
>
=
What is the correct syntax to declare an array in C?
int arr[5];
array int arr[5];
arr int[5];
int[] arr;
Which of the following is a valid format specifier for an integer in C?
%d
%f
%s
%c
Which of the following is used to terminate a loop in C?
exit
break
continue
return
What is the output of the following code? int a = 5, b = 10; printf("%d", a + b);
10
5
15
Compilation error
Which of the following loops is used when the number of iterations is known?
for loop
while loop
do-while loop
goto loop
Which function is used to calculate the length of a string in C?
strlen()
strcat()
strcmp()
scanf()
What is the purpose of the continue statement in C?
To stop the loop
To skip the current iteration and move to the next one
To end the program
To declare a variable
Which data type is used to store a single character in C?
char
string
int
float
What is the result of 10 / 3 in C?
3.33
3
4
Compilation error
what will be the output of following code?
int a=10;
printf(if(a==10));
-1
error
1
0
What is the output of the following code? int a = 5; if (a > 0) printf("Positive"); else printf("Negative");
Positive
Negative
Error
5
Which of the following operators is used for logical AND in C?
&
&&
||
!
