wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Programming in C Week 1-5(All C topics)

Total questions: 102

Worksheet time: 4hrs 35mins

Name
Class
Date
1.

int main()


{


int a = 10, b = 25;


a = b++ + a++;


b = ++b + ++a;


printf("%d %d n", a, b);


}

a)

36 64

b)

35 62

c)

36 63

d)

30 28

2.

#include<stdio.h>

int main()

{

float a=0.7;

if(a<0.7)

{

printf("C");

}

else

{

printf("C++");

}

}

a)

C

b)

C++

c)

Compilation Error

d)

None of the these

3.

int main() {


int m = -10, n = 20;


n = (m < 0) ? 0 : 1;


printf("%d %d", m, n);


}

a)

-10 0

b)

10 20

c)

20 -10

d)

0 1

4.

#include<stdio.h>

int main()

{

int a=2,b=7,c=10;

c=a==b;

printf("%d",c);

}

a)

0

b)

7

c)

2

d)

Compilation error

5.

What is the output of C Program.?

int main()

{

int a=5;

while(a >= 3);

{

printf("RABBIT\n");

break;

}

printf("GREEN");

return 0;

}

a)

GREEN

b)

RABBIT GREEN

c)

RABBIT is printed infinite times

d)

None of the above

6.

What is the output of C Program.?

int main()

{

int a=25;

while(a <= 27)

{

printf("%d ", a);

a++;

}

return 0;

}

a)

25 25 25

b)

25 26 27

c)

27 27 27

d)

Compiler error

7.

What is the output of C Program.?

int main()

{

int a=32;

do

{

printf("%d ", a);

a++;

}

while(a <= 30);

return 0;

}

a)

32

b)

33

c)

30

d)

No Output

8.

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

9.

Choose a correct C Statement.

a)

a++ is (a=a+1) POST INCREMENT Operator

b)

a-- is (a=a-1) POST DECREMENT Operator

--a is (a=a-1) PRE DECREMENT Operator

c)

++a is (a=a+1) PRE INCREMENT Operator

d)

All the above.

10.

What is the output of C Program.?

int main()

{

int k;

for(;;)

{

printf("TESTING\n");

break;

}

return 0;

}

a)

No Output

b)

TESTING

c)

Compiler error

d)

None of the above

11.

What is the way to suddenly come out of or Quit any Loop in C Language.?

a)

continue; statement

b)

break; statement

c)

leave; statement

d)

quit; statement

12.

Choose correct C while loop syntax.

a)

while(condition) { //statements }

b)

{ //statements }while(condition)

c)

while(condition); { //statements }

d)

while() { if(condition) { //statements } }

13.

Choose a correct C for loop syntax.

a)

for(initalization; condition; incrementoperation) { //statements }

b)

for(declaration; condition; incrementoperation) { //statements }

c)

for(declaration; incrementoperation; condition) { //statements }

d)

for(initalization; condition; incrementoperation;) { //statements }

14.

What is the output of C Program.?

int main()

{

int a=5;

while(a==5)

{

printf("RABBIT");

break;

}

return 0;

}

a)

RABBIT is printed unlimited number of times

b)

RABBIT

c)

Compiler error

d)

None of the above.

15.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int i = 0;

do {

i++;

printf("In while loop\n");

} while (i < 3);

}

a)

In while loop

In while loop

In while loop

b)

In while loop

In while loop

c)

Depends on the compiler

d)

Compile time error

16.
Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?
a)
rem = 3.14 % 2.1;
b)
rem = modf(3.14, 2.1);
c)
rem = fmod(3.14, 2.1);
d)
Remainder cannot be obtain in floating point division
17.
Global variable are available to all functions. Does there exist a mechanism by way of which it available to some and not to others.
a)
Yes
b)
No
18.

When applied to a variable, what does the unary "&" operator yield?

a)

The variable's address

b)

The variable's right value

c)

The variable's binary form

d)

The variable's value

19.

The operator "&" is used for

a)

Bitwise AND

b)

Bitwise OR

c)

Logical AND

d)

Logical OR

20.

The size of a character variable in C is

a)

8 bytes

b)

4 bytes

c)

2 bytes

d)

1 byte

21.

The words if, else, auto, float etc. have predefined meaning and users cannot use them as variables.


These words are called

a)

keywords

b)

identifier

c)

data types

d)

constant

22.

Which operators perform operations on data in binary level?

a)

Logical operator

b)

Bitwise operator

c)

Additional opertors

d)

None of the above

23.

What is the value of this expression using integer arithmetic:

7 / 4

a)

1

b)

2

c)

1.75

24.

Determine the value of this expression using integer arithmetic:

5 % 7

a)

0

b)

2

c)

5

25.

Relational operator

a)

+

b)

=

c)

==

d)

/

26.

a=2;b=6; (a<b):10:15

a)

10

b)

15

c)

2

d)

6

27.

After first pass the answer for x=5-6/3+8*2-1

a)

5-2+8*2-1

b)

5-6/3+16-1

c)

5-2+16-1

d)

-1/3+8*2-1

28.

%s indicates in scanf statement

a)

to get an integer

b)

to get a character

c)

to get a string

d)

to get a real no.

29.

What is the data type use for whole number?

a)

%ld

b)

%f

c)

%lf

30.

What operator that will be perform last in a given equation?

a)

+

b)

/

c)

%

31.

What format specifier is use for double data type?

a)

%lf

b)

%d

c)

%f

32.
What is an interpreter?
a)
Converts source code one instruction at a time
b)
Converts source code between 2 HLLs
c)
Converts source code between HLL and Assembly
d)
Converts keyboard presses to an ASCII code
33.
What would you use to convert high-level source code to machine code?
a)
Linker
b)
Assembler
c)
Compiler
d)
IDE
34.

Which should be the printf statement of the following program:

void main()

{

int age = 10;

printf...

}

a)

printf("I am %d years old.\n");

b)

printf("I am %f years old.\n", age);

c)

printf("I am %s years old.\n");

d)

printf("I am %d years old.\n", age);

35.

Check the following code segment and try to predict what's going to happen?

#include <stdio.h>

int main(){

int x=++2;

printf("%d",x);

return 0;

}

a)

3 will be printed on compilation and execution.

b)

2 will be printed on compilation and execution.

c)

compilation error - "Ivalue required".

d)

runtime error.

36.

Libray function getch() belongs to which header file?

a)

stdio.h

b)

conio.h

c)

stdlib.h

d)

stdlibio.h

37.

What is the value of X in the sample code given below?

X = ( 2 + 3) * 2 + 3;

a)

10

b)

13

c)

25

d)

28

38.

What value will be stored in z if the following code is executed?

x = 5 , y = -10, a = 4, b = 2;

z = x+++++y * b/a;

a)

-2

b)

0

c)

1

d)

2

39.

#include <stdio.h>

int main()

{

int x = 2, y = 2;

x /= x / y;

printf(“%d\n”, x);

return 0;

}

a)

a) 2

b)

b) 0.5

c)

c) 1

d)

d) Undefined behaviour shown

40.

#include <stdio.h>

int main()

{

int x = 2, y = 1;

x *= x + y;

printf("%d\n", x);

return 0;

}

a)

a) 6

b)

b)5

c)

c) Undefined behavior shown

d)

d) Compilation time error

41.

#include<stdio.h>

void main()

{

int a=5;

int b=6;

a++;

b++;

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

}

a)

5 6

b)

6 7

c)

5 7

d)

Compilation Error

42.

#include<stdio.h>

int main()

{

int x;

for(x=-1; x<=10; x++)

{

if(x < 5)

continue;

else

break;

printf("SKCT");

}

return 0;

}

a)

A.Infinite times

b)

B. 11 times

c)

C. 0 times

d)

D.10 times

43.

#include<stdio.h>

int main()

{

int i=0;

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

printf("%d", i);

return 0;

}

a)

Compilation Error

b)

6

c)

012345

d)

12345

44.

#include<stdio.h>

int main()

{

float a = 0.7;

if(0.7 > a)

printf("Hi\n");

else

printf("Hello\n");

return 0;

}

a)

A.Hi

b)

B. Hello

c)

C. Hi Hello

d)

D.None of above

45.

#include<stdio.h>

int main()

{

int k, num = 30;

k = (num < 10) ? 100 : 200;

printf("%d\n", num);

return 0;

}

a)

A.200

b)

B. 30

c)

C. 100

d)

D.500

46.

#include<stdio.h>

int main()

{

int a = 300, b, c;

if(a >= 400)

b = 300;

c = 200;

printf("%d, %d, %d\n", a, b, c);

return 0;

}

a)

A.300, 300, 200

b)

B. Garbage, 300, 200

c)

C. 300, Garbage, 200

d)

D.300, 300, Garbage

47.

#include<stdio.h>

int main()

{

char j=1;

while(j < 5)

{

printf("%d, ", j);

j = j+1;

}

printf("\n");

return 0;

}

a)

1 2 3 ... 127

b)

1 2 3 ... 255

c)

1 2 3 ... 127 128 0 1 2 3 ... infinite times

d)

1, 2, 3, 4

48.

The modulus operator cannot be used with a long double.

a)

True

b)

False

49.

What is the output of C Program.?

int main()

{

int a=25;

while(a <= 27)

{

printf("%d ", a);

a++;

}

return 0;

}

a)

25 25 25

b)

25 26 27

c)

27 27 27

d)

Compiler error

50.

What is the output of C Program.?

int main()

{

int k, j;

for(k=1, j=10; k <= 5; k++)

{

printf("%d ", (k+j));

}

return 0;

}

a)

compiler error

b)

10 10 10 10 10

c)

10 11 12 13 14 15

d)

None of the above

51.

What is the output of C Program.?

int main()

{

int k;

for(k=1; k <= 5; k++);

{

printf("%d ", k);

}

return 0;

}

a)

1 2 3 4 5

b)

1 2 3 4

c)

6

d)

5

52.

int main()


{


int a = 10, b = 25;


a = b++ + a++;


b = ++b + ++a;


printf("%d %d n", a, b);


}

a)

36 64

b)

35 62

c)

36 63

d)

30 28

53.

int main()


{


char arr[7]="Network";


printf("%s", arr);


return 0;


}

a)

Network

b)

N

c)

Garbage Value

d)

Compilation error

54.

#include<stdio.h>

int main()

{

char arr[11]="The African Queen";

printf("%s",arr);

}

a)

The African Queen

b)

The

c)

The African

d)

Compilation error

55.

int main ()


{


int x = 24, y = 39, z = 45;


z = x + y;


y = z - y;


x = z - y;


printf ("n%d %d %d", x, y, z);


}

a)

24 39 63

b)

39 24 63

c)

24 39 45

d)

39 24 45

56.

int main()


{


int a = 1, b=2, c=3;


char d = 0;


if(a,b,c,d)


{


printf("EXAM");


}


}

a)

No Output and No Error

b)

EXAM

c)

Run time error

d)

Compile time error

57.

What will be output of the following c program?

#include<stdio.h>

int main()

{

int max-val=100;

int min-val=10;

int avg-val;

avg-val = max-val + min-val / 2;

printf("%d",avg-val);

}

a)

55

b)

105

c)

60

d)

Compilation error

58.

Diamond shaped symbol is used in flowcharts to show the-

a)

decision box

b)

statement box

c)

error box

d)

if-statement box

59.

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

a)

int a3;

b)

int 3a;

c)

int _A3;

d)

int a_3

60.

#include <stdio.h>

int main()

{

signed char chr;

chr = 128;

printf("%d\n", chr);

return 0;

}

a)

128

b)

0

c)

-128

d)

Garbage Value

61.

What is the output of following program?

a)

20

b)

30

c)

Compile Error

d)

Runtime Error

62.

Arrays always occupy contiguous memory area

a)

True

b)

False

63.

Which of the following format specifier in printf is used to print pointers?

a)

%c

b)

%d

c)

%f

d)

%p

64.

A pointer is

a)

A keyword used to create variables

b)

A variable that stores address of an instruction

c)

A variable that stores address of a varaibe

d)

All of the above

65.

What is the & in pointers?

a)

Dereferences the memory address into an object

b)

References an object into a memory address

c)

Makes a new copy of the object as a memory address

d)

None of the above.

66.

How do you make a pointer point to an existing variable?

int y = 0;

a)

int *x = y;

b)

int x = y;

c)

int *x = &y;

d)

int &x = *y;

67.

#include <stdio.h> double i; int main() { printf("%g\n",i); return 0; }

a)

0

b)

0.000000

c)

Garbage value

d)

Depends on the compiler

68.

Which operator connects the structure name to its member name?

a)

b)

<-

c)

.

d)

Both <- and .

69.

Which of the following cannot be a structure member?

a)

Another structure

b)

Function

c)

Array

d)

None of the mentioned

70.

Computer memory locations are

a)

Bi linear

b)

Linear

c)

Non Linear

71.

Computer address values in reality are in

a)

Decimal

b)

Binary

c)

Hexadecimal

d)

C code

72.

printf("%d", &C), prints

a)

value of C

b)

Address of C

c)

Error message

d)

None of the above

73.

If 5 is added to the address value 'A' of an integer variable the new address is

a)

A +5

b)

A+ 10

c)

A+ 20

d)

Data insufficient

74.

In a C Program if

int a = 5;

Int *ptr = &a;

then the printf statement with

&a, a, *ptr , ptr

a)

adrress, Value, Value, Adress

b)

address, value, value, value

c)

all address

d)

All values

75.

In a C Program if

int a = 5;

Int *ptr = &a;

printf ("%d" , ptr)

gives

a)

5

b)

address of a

c)

address of ptr

d)

none

76.

A double pointer points

a)

address of an integer

b)

address of a pointer

c)

value stored in the memory

d)

None

77.

In a C program,

int a = 20;

*ptr = &a;

**dptr = &ptr;

printf ("%d", **dptr);


prints

a)

address of a

b)

address of ptr

c)

value of a

d)

address of dptr

78.

Which of the following pointer is Wild

a)

int *p;

b)

int *q=&a;

c)

int *v=NULL;

d)

void *g;

79.

What is the main drawback of pointers

a)

Complexity to mange pointers

b)

Difficult to write program

c)

They are not safe

80.

What is the output of the following Code:

#include <stdio.h>

int main()

{

int *p;

int a=10;

p=&a;

*p=34;

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

return 0;

}

a)

34,34

b)

10,10

c)

10,34

d)

34,10

81.

What is the output of the following code:

#include <stdio.h>

int main()

{

void *z;

float s=1.2;

z=&s;

printf("%f",*z);

return 0;

}

a)

Compile time error

b)

1.20000

c)

1.2

d)

Run time error

82.

What is the output of the following code snippet:


int a=45,b=67;

int *s,*q;

s=&a;q=&b;

printf("%d",s+q);

a)

Compile time error

b)

112

c)

Garbage value

d)

0

83.

Which of the following operators are not used with pointers

a)

*

b)

/

c)

%

d)

-

84.

What is the output of the following code:


int a[]={1,2,33,4,4,6}

int *p;

p=a;

*(p+2)=25;

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

a)

25,25

b)

25,4

c)

25, garbage value

d)

Compile time error

85.

Which of the following pointers leads to memory leaks

a)

Wild Pointers

b)

Dangling Pointers

c)

NULL Pointers

d)

Generic Pionters

86.

Which of the following is related to pointer to an array concept in C

a)

int a[]={1,2,2,22};

int *p;

p=a;

b)

int (*p)[3];

int a[]={1,2,3};

p=&a;

c)

int *p[3];

int a[]={1,2,2};

p=a;

d)

int **a[];

87.

What is the output of the following code snippet:


char s[]="Ruler";

char p[]="Simha";

strcat(p,s);

printf("%s,%s",p,s);

a)

SimhaRuler,Ruler

b)

Simha,Ruler

c)

RulerSimha,Ruler

d)

Ruler,Simha

88.

What is the output of the following code snippet:


char s[]="Syeraa";

char p[]="NarasimhaReddy";

printf("%d",strcmp(p,s));

a)

5

b)

-5

c)

Not Equal

d)

6

89.

In C language Strings are _______________

a)

Mutable

b)

Immutable

c)

Both Mutable and Immutable

d)

No Mutable and immutable concept in C

90.

What is the output of the following code snippet:


char s[]="Mari-2";

printf("%s",strupr(s));

a)

MARI-2

b)

mari-2

c)

MARI**

d)

Invalid string

91.

What is the output of the following code snippet:


char s[]="Saaho";

printf("%d,%d",strlen(s),sizeof(s));

a)

5,5

b)

6,6

c)

5,6

d)

5,1

92.

What is the answer for the following code:


int a=20;

printf("%p",a);

a)

0014

b)

14

c)

32

d)

20

93.

Which of the following are themselves a collection of different data types?

a)

String

b)

Struct

c)

char

d)

all

94.

Which operator connects the structure name to its member name?

a)

-

b)

=

c)

.

d)

>>

95.

Which of the following cannot be a structure member?

a)

another structure

b)

array

c)

Function

d)

None

96.

Which of the following structure declaration will throw an error?

a)

struct temp{ } s;

main(){}

b)

struct temp{ };

struct temp s;

main(){ }

c)

struct temp s;

struct temp{ };

main(){ }

d)

None

97.

What is the output of this C code?

void main()

{

struct student

{

int no;

char name[20];

};

struct student s;

s.no = 8;

printf("%d", s.no);

}

a)

Nothing

b)

Compile error

c)

8

d)

Junk

98.

Size of a union is determined by size of the.

a)

First member in the union

b)

Last member in the union

c)

C. Biggest member in the union

d)

Sum of the sizes of all members

99.

Assuming size of long int is 4 bytes, what will be the output for:


typedef long long int L = 24;

printf("Size of long long int is :");

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

a)

24

b)

4

c)

8

d)

Error

100.

What will be the output

a)

Name:

Subject:

Percentage: 86.50000

b)

Name:Raju

Subject:

Percentage: 86.50000

c)

Name: Raju

Subject: Maths

Percentage: 86.50000

d)

Error

101.

Memory allocated for structure members are always contigious

a)

True

b)

False

102.

What do you understand by:

void update(struct student *s);

a)

update is a function that takes an argument as pointer to structure variable and returns nothing

b)

update is a method that takes structure type variable as parameter

c)

Error, we cannot pass structure variable as pointer to a function

d)

update takes pointer argument but it cannot return void