NEW
Font size
WorksheetsRound_1 (B)| Coding Combat 2.0
Total questions: 30
Worksheet time: 15mins
What is the syntax to declare a variable in C?
variableType variableName;
var variableName;
variableName = value;
nt variableName;
Who is the father of C language?
Steve Jobs
James Gosling
Dennis Ritchie
Rasmus Lerdorf
Which of the following is not a valid C variable name?
int number;
float rate;
int variable_count;
int $main;
What is the output of the following C code snippet?
int x = 5;
int y = 10;
int z = x + y;
printf("%d", z);15
10
5
20
Which header file is used for input and output functions in C?
stdio.h
math.h
stdlib.h
string.h
What is the purpose of the 'break' statement in C?
To exit the loop immediately
To skip the current iteration and move to the next
To define a case in switch statement
To continue the loop from the beginning
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
What will be the output of the following code snippet?
#include <stdio.h> int main() { int a = 3, b = 5; int t = a; a = b; b = t; printf("%d %d", a, b); return 0; }
3.5
3.3
5.5
5.3
What is the purpose of the 'continue' statement in C?
To exit the loop immediately
To skip the current iteration and move to the next
To define a case in switch statement
To restart the loop from the beginning
Which of the following is true for functions in C?
Functions cannot return values
Functions can only be called once in a program
Functions can be recursive
Functions cannot have parameters
What is the output of the following C code snippet?
int a = 10;
int b = 3;
int c = a % b;
printf("%d", c);3
1
0
10
What is the purpose of the 'void' keyword in C?
To declare a function that does not return any value
To declare a variable without assigning a value
To define a constant value
To specify the size of a data type
Which operator is used for pointer dereferencing in C?
&
*
->
::
What is the output of the following C code snippet?
int i = 5;
int j = 2;
float result = (float)i / j;
printf("%f", result);2.5
2
2.0
2.2
What is the purpose of the 'if' statement in C?
To exit the loop immediately
To skip the current iteration and move to the next
To define a case in switch statement
To conditionally execute a block of code
What is the output of the following C code snippet?
int x = 7;
int y = 2;
int z = x / y;
printf("%d", z);3
2
3.5
2.5
What is the syntax to define a constant in C?
const variableType constantName = value;
constantType constantName = value;
variableType constantName = value;
constantName = value;
Which of these is NOT a relational or logical operator?
=
||
==
!=
What is the purpose of the 'sizeof' operator in C?
To return the size of a variable or data type
To perform addition operation
To compare two variables
To exit the loop immediately
Which of the following is true for the 'switch' statement in C?
It can only be used with integers
It can only have one case
It can have multiple cases with the same value
It is used to define a function
What is the output of the following C code snippet?
int a = 5;
int b = 2;
int c = a * b;
printf("%d", c);7
10
3
12
We cannot use the keyword ‘break’ simply within _________.
while
for
if-else
do-while
What is the purpose of the 'do-while' loop in C?
To execute a block of code repeatedly as long as the condition is true
To execute a block of code only once
To skip the current iteration and move to the next
To define a case in switch statement
What is the output of the following C code snippet?
int x = 8;
int y = 3;
int z = x - y;
printf("%d", z);5
3
8
2
Which of the following is true for arrays in C?
Arrays can only store elements of the same data type
Arrays can dynamically resize during runtime
Arrays cannot be passed to functions
Arrays cannot have more than 10 elements
The correct format of declaring a function is:
type_of_return name_of_function (argument type);
type_of_return name_of_function (argument type){}
type_of_return (argument type) name_of_function;
all of the above
What is the purpose of the 'while' loop in C?
To execute a block of code repeatedly as long as the condition is true
To execute a block of code only once
To skip the current iteration and move to the next
To define a case in switch statement
What is the output of the following C code snippet?
int x = 4;
int y = 3;
int z = x % y;
printf("%d", z);1
2
0
3
Which of the following is true for the 'for' loop in C?
It can only be used with integers
It can only have one case
It can have multiple cases with the same value
It is used to define a function
Which of these is the correct initialization method for the following:
typedef char *string;
More than a single space shouldn’t be given when we are using typedef
*string p = ‘A’;
string p = “Hello”;
*string p = “Hello”;
