NEW
Font size
WorksheetsQUIZ
Total questions: 30
Worksheet time: 28mins
Which of the following is a valid identifier in C ?
int
_var123
123var
#define
If no return type is specified for a function, what is its default return type in C?
void
int
float
Compiler error
Which header file is required for printf() and scanf()?
stdlib.h
stdio.h
conio.h
math.h
We use malloc and calloc for:
Dynamic memory allocation
Static memory allocation
Both dynamic memory allocation and static memory allocation
None of these
Full form of ASCII?
African Standard Code for Information Interchange
American Standard Code for International Interchange
American Standard Code for International Intermediate
American Standard Code for Information Interchange
Who is known as Mother of computer?
Charles Babbage
Alan Turing
Grace Hopper
Ada Lovelace
Which of the following is NOT a reserved keyword in C?
extern
static
bool
register
What will printf("%d", 2 == 3);
print ?
0
1
Compilation error
None of the above
What will be the output of following?
void main(){
int const* p = 5;
printf("%d", ++(*p));
}
6
5
Garbage Value
Compiler Error
What will be the output of following?
void main() {
int i = 0;
printf("%d %d", i, i++);
}
0 1
1 0
0 0
1 1
Which operator is used to obtain the address of a variable?
*
&
->
.
Which of the following statements about for, while, and do-while loops is true?
The for loop executes faster than the while loop.
A do-while loop is always better than a while loop.
A for loop can always be rewritten as a while loop, but the reverse is not always true.
A loop must always have an increment or decrement statement inside it.
What does return 0;
at the end of main() indicate?
Program error
Successful execution
Undefined behavior
None
How do you declare an array of 10 integers?
int arr[10];
arr[10] = int;
array int arr[10];
int arr(10);
Who is the founder of the C programming language?
James Gosling,1992
James Gosling,1972
Dennis Ritchie,1972
Dennis Ritchie,1992
Which function is use to add two strings?
strcpy()
strcat()
strcmp()
strncmp()
Assume that if the initial address of the array is 1000 , and the size of the array is 10. If integers are added in 7th position then what is the address of the newly inserted integer?
1032
1031
1028
1024
Consider the following C program:
#include < stdio.h >
int main(){
int a = 6;
int b = 0;
while(a < 10) {
a = a / 12 + 1;
a += b;}
printf("%d", a);
return 0;}
Which one of the following statements is CORRECT?
The program prints 1 as output
The program prints 10 as Output
The program gets stuck in an infinite loop
The program prints 6 as output
#include < stdio.h >
int funcp(){
static int x = 1;
x++;
return x;
}
int main(){
int x,y;
x = funcp();
y = funcp()+x;
printf("%d\n", (x+y));
return 0;
}
3
5
6
7
Convert the following decimal to binary:
(180)
10110110
10110100
10101010
10111100
How many times will the loop execute?
#include <stdio.h>
int main() {
for (int i = 1; i < 10; i += 3) {
printf("%d ", i);
}
return 0; }
2 times
3 times
4 times
5 times
What is the output?
#include <stdio.h>
int main() {
int a = 5, b = 0;
if (a && b)
printf("Yes");
else
printf("No");
return 0;
}
Yes
No
Compilation Error
Runtime Error
How do you return multiple values from a function in C?
Use global variables
Use pointers or structures
Use arrays only
C does not allow multiple returns
Which keyword is used to prevent a variable from being modified within a function?
volatile
const
restrict
static
How is a string terminated in C?
\n
.
\0
EOF
Which of the following is used to declare a structure in C?
struct
class
union
enum
Which operator has the highest precedence?
* (multiplication)
++ (postfix increment)
++ (prefix increment)
& (address-of)
47. What is the output of the following snippet?
int a = 5;
printf("%d", a--);
4
5
6
Undefined
#include <stdio.h>
int main()
{
int x;
x = 5 > 8 ? 10 : 1 != 2 < 5 ? 20 : 30;
printf("Value of x:%d", x);
return 0;
}
30
40
10
20
Which of the following statements about loops in C is incorrect?
A for loop can be written without any condition, making it an infinite loop.
The while loop is guaranteed to execute at least once.
The do-while loop always executes at least once, even if the condition is false.
A break statement can be used to exit any loop prematurely.
