wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Basic of C

Total questions: 10

Worksheet time: 10mins

Name
Class
Date
1.

Predict the output


#include <stdio.h>

int var = 20;int main(){

int var = var;

printf("%d ", var);

return 0;

}

a)

Garbage Value

b)

20

c)

Compile Time Error

d)

None of these

2.

What will be the output?


int main(){

{

int var = 10;

}

{

printf("%d", var);

}

return 0;

}

a)

Compile Time Error

b)

10

c)

Garbage Value

d)

None of these

3.

int main()

{

int x = 032;

printf("%d", x);

return 0;

}

a)

32

b)

26

c)

0

d)

50

4.

int main()

{

int a=5,b=6,max;

a<b?max=b:max=a;

printf("%d",max);

return 0;

}

a)

6

b)

Compile Time Error

c)

Run Time Error

d)

None of these

5.

What will be the output?


int main()

{

char c = 125;

c = c+10;

printf("%d", c);

return 0;

}

a)

135

b)

-121

c)

-8

d)

Compile time error

6.

#include <stdio.h>


int main()

{

if (sizeof(int) > -1)

printf("Yes");

else

printf("No");

return 0;

}

a)

Yes

b)

No

c)

Compiler Error

d)

Run time Erroe

7.

What will be the output?

Note: Consider size:( int 2 bytes) ,(float 4 bytes), (double 8 Bytes)


int main()

{

printf("%d", sizeof(3.5));

return 0;

}

a)

4

b)

8

c)

2

d)

None of these

8.

What will be the output?

Note: Consider size:( int 2 bytes) ,(float 4 bytes), (double 8 Bytes)


int main()

{

printf("%d", sizeof(!3.5));

return 0;

}

a)

4

b)

8

c)

2

d)

None of these

9.

What will be the output?


int main()

{

int n;

int i=printf("Hello world");

n=i+10;

printf("%d",n);

}

a)

21

b)

Hello world

c)

Hello world21

d)

Compiler Error

10.

What will be the output?


int main()

{

int n=10;

printf(1+"%d",n);

}

a)

10

b)

0

c)

d

d)

Compiler Error