wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

'C'Programming Basics - Prepared by Feroz Khan A.B

Total questions: 15

Worksheet time: 21mins

Name
Class
Date
1.

#include<stdio.h>


main()

{

int x = 1;

do

printf("%d ", x);

while(x++<=1);

}

a)

1

b)

Error

c)

1 2

d)

No output

2.

Compiler generates ___ file.

a)

Executable code

b)

Object code

c)

Assembly code

d)

All of the above

3.

What is the built in library function to compare two strings?

a)

string_cmp()

b)

strcmp()

c)

equals()

d)

str_compi()

4.

Which of the following is not a valid variable name declaration?

a)

int __a3;

b)

int __3a;

c)

int a_3;

d)

None of the aove

5.

#include<stdio.h>

int main()

{

static int var = 5;

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

if(var)

main();

}

a)

5 4 3 2 1

b)

5 5 5 5 5

c)

0 0 0 0 0

d)

5

6.

#include<stdio.h>

int main()

{

static int i=5;

if(--i){

main();

printf("%d ",i);

}

}

a)

5 5 5 5 5

b)

5 4 3 2 1

c)

0 0 0 0 0

d)

Error

7.

#include<stdio.h>

int main()

{

int x;

printf("%d",scanf("%d",&x));

/* Suppose that input value given

for above scanf is 20 */

return 1;

}

a)

20

b)

Error

c)

1

d)

0

8.

# include <stdio.h>

int main()

{

int i=0;

for(i=0; i<20; i++)

{

switch(i)

{

case 0:

i+=5;

case 1:

i+=2;

case 5:

i+=5;

default:

i+=4;

break;

}

printf("%d ", i);

}


getchar();

return 0;

}

a)

21

b)

16

c)

16 21

d)

None

9.

All keywords in C are in ____________

a)

LowerCase letters

b)

UpperCase letters

c)

CamelCase letters

d)

All of the above

10.

What is required in each C program?

a)

The program must have at least one function.

b)

The program does not require any function.

c)

Input data

d)

Output data

11.

main() { int i = 2;

{ int i = 4, j = 5;

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

}

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

}

a)

4525

b)

2525

c)

4545

d)

Error

12.

What is the output of this statement "printf("%d", (a++))"?

a)

The value of (a + 0)

b)

The current value of a

c)

0

d)

Garbage

13.

How many times will the following loop execute?

for(j = 1; j <= 10; j = j-1)

a)

Forever

b)

Never

c)

0

d)

1

14.

What is the result after execution of the following code if a is 10, b is 5, and c is 10?

If ((a > b) && (a <= c))

a = a + 1;

else

c = c+1;

a)

a = 10, c = 10

b)

a = 11, c = 10

c)

a = 10, c = 11

d)

a = 11,c = 11

15.

Which one of the following is a loop construct that will always be executed once?

a)

for

b)

while

c)

if

d)

do while