wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Day 3 {C} Quiz

Total questions: 10

Worksheet time: 6mins

Name
Class
Date
1.

If the two strings are identical, then strcmp() function returns?

a)

-1

b)

1

c)

0

d)

Yes

2.

int main()

{

char str1[20] = "Hello", str2[20] = " World";

printf("%s", strcpy(str2, strcat(str1, str2)));

return 0;

}

a)

Hello

b)

World

c)

Hello World

d)

WorldHello

3.

Which of the following accesses a variable in structure b?

a)

b->var;

b)

b.var;

c)

b-var;

d)

b>var;

4.

Which of the following is a properly defined struct?

a)

struct {int a;}

b)

struct a_struct {int a;}

c)

struct a_struct int a;

d)

struct a_struct {int a;};

5.

void fun(int *ptr){

*ptr = 30;

}

int main(){

int y = 20;

fun(&y);

printf("%d", y);

}

a)

20

b)

30

c)

Compiler Error

d)

Runtime Error

6.

int main()

{

int arr[] = {1, 2, 3, 4, 5};

int *p = arr;

++*p;

p += 2;

printf("%d", *p);

return 0;

}

a)

2

b)

3

c)

4

d)

Compile error

7.

void f(int *p, int *q)

{

p = q;

*p = 2;

}

int i = 0, j = 1;

int main()

{

f(&i, &j);

printf("%d %d n", i, j);

}

a)

0 2

b)

2 2

c)

2 1

d)

2 0

8.

Which of the following is not true about a structure?

a)

Structure are used to construct a complex data type in a meaningful way

b)

We can also declare an array of Structure.

c)

A Structure can be nested inside under Structure.

d)

We cannot pass a structure as a function argument

9.

What’s the size returned for each of sizeof() operator?


char *pChar;

int *pInt;

float *pFloat;

sizeof(pChar);

sizeof(pInt);

sizeof(pFloat);

a)

4 4 4

b)

1 4 4

c)

1 4 8

d)

None of the above.

10.

What is the value of **p2?


int a = 10;

int *p1 = &a;

int **p2 = &p1

a)

Address of a

b)

Address of p1

c)

Value of a