wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PROGRAMMING IN C CO-1,2

Total questions: 50

Worksheet time: 50mins

Name
Class
Date
1.

1. 

 What is the range of values that can be stored by int datatype in C?

a)

-(2^31)to(2^31)-1

b)

-256 to 255

c)

-(2^63)to(2^63)-1

d)

0 to(2^31)-1

2.

What will be the output of the following code snippet?

#include <stdio.h>
int main() {
	int a = 3, b = 5;
	int t = a;
	a = b;
	b = t;
	printf("%d %d", a, b);
	return 0;
}
a)

3 5

b)

3 3

c)

5 5

d)

5 3

3.

Final step of the for loop is ----------------------------

a)

Incrementing

b)

decrementing

c)

Both

d)

Incrementing / decrementing

4.

What is the sizeof(char) in a 32-bit C compiler?

a)

1 bit

b)

2 bits

c)

1 Byte

d)

2 Bytes

5.

Which is valid C expression?

a)

int my_num = 100000;

b)

int my_num = 100,000;

c)

int my num = 1000;

d)

int $my_num = 10000;

6.

scanf() is a predefined function in______header file.

a)

stdarg. h

b)

iostream.h

c)

conio.h

d)

stdio.h

7.

Which of the following is not a high level programming language?

a)

Assembly

b)

C++

c)

Java

d)

Python

8.

Conditional operators are used for decision making in C.

4 lines
9.

int x;

int y;

int z;

x=3;

y=4;

z = ++x * y++;

printf("%d",z);

a)

12

b)

16

c)

20

d)

0

10.

The output of an arithmetic expression with integer and float is __________.

a)

int

b)

float

c)

can't be defined

d)

operation not possible

11.

#include <stdio.h>


void main()

{


int x = 5 * 9 / 3 + 9;


}

a)

24

b)

3

c)

23

d)

4

12.

!= is the example of ____________________ operator.

a)

Relational

b)

Logical

c)

Assignment

d)

Conditional

13.

What is the value of EOF?

a)

-1

b)

1

c)

0

d)

10

14.

What will be the value of x in the following code snippet?

#include <stdio.h>
void solve() {
    int x = printf("Hello");
    printf(" %d", x);
}
int main() {
	solve();
	return 0;
}
a)

10

b)

5

c)

1

d)

0

15.

Which of the following is the proper syntax for declaring macros in C?

a)

#define long long II

b)

#define II long long

c)

#define II

d)

#define long long

16.

What is the output of the following code snippet?

int main() {
	int sum = 2 + 4 / 2 + 6 * 2;
	printf("%d", sum);
	return 0;
}
a)

2

b)

15

c)

16

d)

18

17.

How do you initialize an array in C?

a)

int arr[3] = (1,2,3);

b)

int arr(3) = {1,2,3};

c)

int arr[3] = {1,2,3}

d)

int arr(3) = (1,2,3)

18.

#include <stdio.h>

#define ERRMSG(a) printf("Error=%d",a);

int main()

{

ERRMSG(10);

return 0;

}

a)

Error=10

b)

error

c)

no output

19.

What are the types of C Preprocessor Directives.?

a)

Macros

b)

Conditional Compilation

c)

File Inclusion

d)

All the above

20.

#include <stdio.h>

#define message_for(a, b) \

printf(#a " and " #b ": are alphabets!\n")

int main(void) {

message_for(C,D);

return 0; }

a)

error

b)

C and D are alphabets

c)

C "and" D are alphabets

21.
a)

Compilation error

b)

macro25 = 47

c)

macro47 = 25

d)

Runtime error

22.

#include <stdio.h>

#define MAX(x,y) ((x) > (y) ? (x) : (y))

int main(void) {

printf("Max between 20 and 10 is %d\n", MAX(10, 20));

return 0; }

a)

10

b)

error

c)

20

d)

Max between 20 and 10 is 20

23.

++ and -- are unary operators.

a)

True

b)

False

24.

What is the output ?

int var;

var = !(0 && (2||1));

printf("%d",var);

a)

0

b)

2

c)

1

d)

Compiler Error

25.

what is the ouput of the below program?


int main()

{

int i=10, j=20;

if((i=100) && (j==20))

{

printf("Have a nice day");

}

else

{

printf("condition not true");

}


return 0;

}

a)

No output

b)

Have a nice day

c)

condition not true

d)

Complier Error

26.
a)

Char 65

b)

Integer 65

c)

Bye

d)

Compilation Error

27.
a)

GREEN

b)

RABBIT

GREEN

c)

RABBIT is printed unlimited number of times.

d)

None of the above

28.

What does the following code fragment write to the monitor?

a)

Under

b)

Over

c)

Under the limit

d)

Over the limit

29.

For loop in a C program, if the condition is missing?

a)

it is assumed to be present and taken to be false

b)

it is assumed to be present and taken to the true

c)

it result in a syntax error

d)

execution will be terminated abruptly

30.

What is the output of C Program.?

int main()

{

int a=32;

do

{

printf("%d ", a);

a++;

if(a > 35)

break;

}

while(1);

return 0;

}

a)

No Output

b)

32 33 34

c)

32 33 34 35

d)

Compiler error

31.
How would you round off a value from 1.66 to 2.0?
a)
ceil(1.66)
b)
floor(1.66)
c)
roundup(1.66)
d)
roundto(1.66)
32.

What is the output of this C code?

a)

Compile time error

b)

Hi Hi

c)

Hi

d)

Varies

33.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int a = 1, b = 1;

switch (a)

{

case a*b:

printf("yes ");

case a-b:

printf("no\n");

break;

}

}

a)

yes

b)

no

c)

yes no

d)

compile time error

34.



(a)  

35.

How to initialize an array in C? tick all the correct statement.

a)

int arr[3] = {1,2,3}

b)

int arr(3) = {1,2,3};

c)

int arr(3) = (1,2,3);

d)

int arr[3] = (1,2,3);

e)

int arr[3] = {0}

36.

How can I store the value 10 into the first row, third column of my array that I have declared as int numbers[10][10]?

a)

int numbers[1][2] = 10;

b)

numbers[0][2] = 10;

c)

numbers[2][3] = 10;

d)

numbers[1][3] = 10

37.
a)

0

b)

1

c)

5

d)

garbage value

e)

Error

38.

Arrays are structures that hold multiple variables of the _____________ data type

a)

int data type

b)

char data type

c)

same data type

d)

different data type

39.

he following program


main( )

{

static int a[ ] = { 7, 8, 9 } ;

printf( "%d", 2[ a ] + a[ 2 ] ) ;

}

a)

results in bus error

b)

results in segmentation voilation error

c)

will not compile successfully

d)

none of these

40.

Given the code, what is in values[2][1] ?

a)

7.9

b)

9.2

c)

7.3

d)

0.5

41.

Predict output of following program

int main(){

int i;

int arr[5] = {1};

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

printf("%d ", arr[i]);

return 0;

}

a)

1 1 1 1 1

b)

1 followed by 4 junk values

c)

1 0 0 0 0

d)

Compiler error

42.

What is the proper declaration for an array that has 2 rows and 3 columns?

a)

type arr[2][2];

b)

arr[2][3] type;

c)

type arr[2][3];

d)

type arr[4][3];

43.

Pick all correct statements.

a)

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

b)

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

c)

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

d)

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

44.

How can I store the value 10 into the second row, first column of my array that I have declared as int numbers[10][10]?

a)

int numbers[1][2] = 10;

b)

numbers[1][2] = 10;

c)

numbers[2][3] = 10;

d)

numbers[1][0] = 10

45.

What is the output of

#include <stdio.h>

int main()

{

    char str[8]="IncludeHelp";

    printf("%s",str);

    return 0;

}

a)

IncludeHelp

b)

IncludeH

c)

Error

d)

No Output

46.

 

Array can be considered as set of elements stored in consecutive memory locations but having __________.

a)

Same data type

b)

Different data type

c)

Same scope

d)

None of these

47.

What is the output of C program with strings.?

int main()

{

char str1[]="SMART";

char str2[10];

str2 = str1;

printf("%s",str2);

return 0;

}

a)

SMART

b)

SMART followed by 5 spaces

c)

SMART followed by 4 spaces

d)

can not assign one string to another

48.

int main()

{

char str[25];

scanf("%s", str);

printf("%s",str);

return 0;

}

//input: South Africa

a)

South

b)

South Africa

c)

S

d)

Compiler error

49.

Which of the following function is more appropriate for reading in a multi-word string?

a)

scanf()

b)

printf()

c)

puts()

d)

gets()

50.

String is an array of characters with …….. character as the last element of array.

a)

Null

b)

Empty

c)

0

d)

1