wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

QUIZ

Total questions: 30

Worksheet time: 28mins

Name
Class
Date
1.

Which of the following is a valid identifier in C ?

a)

int

b)

_var123

c)

123var

d)

#define

2.

If no return type is specified for a function, what is its default return type in C?

a)

void

b)

int

c)

float

d)

Compiler error

3.

Which header file is required for printf() and scanf()?

a)

stdlib.h

b)

stdio.h

c)

conio.h

d)

math.h

4.

We use malloc and calloc for:

a)

Dynamic memory allocation

b)

Static memory allocation

c)

Both dynamic memory allocation and static memory allocation

d)

None of these

5.

Full form of ASCII?

a)

African Standard Code for Information Interchange

b)

American Standard Code for International Interchange

c)

American Standard Code for International Intermediate

d)

American Standard Code for Information Interchange

6.

Who is known as Mother of computer?

a)

Charles Babbage

b)

Alan Turing

c)

Grace Hopper

d)

Ada Lovelace

7.

Which of the following is NOT a reserved keyword in C?

a)

extern

b)

static

c)

bool

d)

register

8.

What will printf("%d", 2 == 3);

print ?

a)

0

b)

1

c)

Compilation error

d)

None of the above

9.

What will be the output of following?

void main(){

    int const* p = 5;

    printf("%d", ++(*p));

}

a)

6

b)

5

c)

Garbage Value

d)

Compiler Error

10.

What will be the output of following?

void main() {

int i = 0;

printf("%d %d", i, i++);

}

a)

0 1

b)

1 0

c)

0 0

d)

1 1

11.

Which operator is used to obtain the address of a variable?

a)

*

b)

&

c)

->

d)

.

12.

Which of the following statements about for, while, and do-while loops is true?

a)

The for loop executes faster than the while loop.

b)

A do-while loop is always better than a while loop.

c)

A for loop can always be rewritten as a while loop, but the reverse is not always true.

d)

A loop must always have an increment or decrement statement inside it.

13.

What does return 0;

at the end of main() indicate?

a)

Program error

b)

Successful execution

c)

Undefined behavior

d)

None

14.

How do you declare an array of 10 integers?

a)

int arr[10];

b)

arr[10] = int;

c)

array int arr[10];

d)

int arr(10);

15.

Who is the founder of the C programming language?

a)

James Gosling,1992

b)

James Gosling,1972

c)

Dennis Ritchie,1972

d)

Dennis Ritchie,1992

16.

Which function is use to add two strings?

a)

strcpy()

b)

strcat()

c)

strcmp()

d)

strncmp()

17.

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?

a)

1032

b)

1031

c)

1028

d)

1024

18.

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?

a)

The program prints 1 as output

b)

The program prints 10 as Output

c)

The program gets stuck in an infinite loop

d)

The program prints 6 as output

19.

#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;

}

a)

3

b)

5

c)

6

d)

7

20.

Convert the following decimal to binary:

(180)

a)

10110110

b)

10110100

c)

10101010

d)

10111100

21.

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; }

a)

2 times

b)

3 times

c)

4 times

d)

5 times

22.

What is the output?

#include <stdio.h>

int main() {

int a = 5, b = 0;

if (a && b)

printf("Yes");

else

printf("No");

return 0;

}

a)

Yes

b)

No

c)

Compilation Error

d)

Runtime Error

23.

How do you return multiple values from a function in C?

a)

Use global variables

b)

Use pointers or structures

c)

Use arrays only

d)

C does not allow multiple returns

24.

Which keyword is used to prevent a variable from being modified within a function?

a)

volatile

b)

const

c)

restrict

d)

static

25.

How is a string terminated in C?

a)

\n

b)

.

c)

\0

d)

EOF

26.

Which of the following is used to declare a structure in C?

a)

struct

b)

class

c)

union

d)

enum

27.

Which operator has the highest precedence?

a)

* (multiplication)

b)

++ (postfix increment)

c)

++ (prefix increment)

d)

& (address-of)

28.

47. What is the output of the following snippet?

int a = 5;

printf("%d", a--);

a)

4

b)

5

c)

6

d)

Undefined

29.

#include <stdio.h>

int main()

{

int x;

x = 5 > 8 ? 10 : 1 != 2 < 5 ? 20 : 30;

printf("Value of x:%d", x);

return 0;

}

a)

30

b)

40

c)

10

d)

20

30.

Which of the following statements about loops in C is incorrect?

a)

A for loop can be written without any condition, making it an infinite loop.

b)

The while loop is guaranteed to execute at least once.

c)

The do-while loop always executes at least once, even if the condition is false.

d)

A break statement can be used to exit any loop prematurely.