wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C Code Based Test

Total questions: 160

Worksheet time: 3hrs 37mins

Name
Class
Date
1.

#include<stdio.h>

int main(){

int i=5;

printf("%d%d%d%d%d",i++,i--,++i,--i,i);

}

a)

4 5 5 4 5

b)

3 4 5 6 1

c)

3 4 4 3 4

d)

6 4 4 6 4

2.

#include<stdio.h>

int main(){

int i;

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

}

a)

1

b)

0

c)

2

d)

3

3.

#include<stdio.h>

#define clrscr() 100

int main(){

clrscr();

printf("%d/n",clrscr());

}

a)

100

b)

101

c)

103

d)

200

4.

int main()

{

char p;

char buf[10] = {1,2,3,4,5,6,9,8};

p=(buf+1)[5];

printf(“%d”,p);

}

a)

8

b)

7

c)

9

d)

6

5.

What will be the output of the following C code snippet?

#include <stdio.h>

void main()

{

1 < 2 ? return 1: return 2;

}

a)

returns 1

b)

returns 2

c)

varies

d)

compile time error

6.

#include<stdio.h>

void f() {

static int i;

++i;

printf("%d", i); }

main(){

f();

f();

f();

}

a)

135

b)

234

c)

123

d)

678

7.

main()

{

Int c = --2;

Printf(“c = %d”,c);

}

a)

1

b)

0

c)

2

d)

Error

8.

int main()

{

int i=-1,j=-1,k=0,l=2,m;

m = i++&&j++&&k++||l++;

printf(“%d%d%d%d%d”,i,j,k,l,m);

}

a)

00131

b)

11242

c)

00242

d)

23456

9.

main(){

int a;

printf(“TIGER COUNT = “);

a = show();}

int show(){

return 15;

return 35;

}

a)

TIGER COUNT =15

b)

TIGER COUNT =30

c)

TIGER COUNT =35

d)

TIGER COUNT =15 35

10.

main()

{

int c[ ]={2.8,3.4,4,6.7,5};

int j,*p=c,*q=c;

for(j=0;j<5;j++) {

printf(" %d ",*c);

++q; }

for(j=0;j<5;j++){

printf(" %d ",*p);

++p; }

}

a)

1 1 1 1 1 1 2 3 4 5

b)

2 2 2 2 2 2 3 4 5 6

c)

2 2 2 2 2 2 3 4 6 5

d)

3 3 3 3 3 3 4 5 6 7

11.

main()

{

extern int i;

i=20;

printf("%d",i);

}

a)

20

b)

25

c)

1

d)

undefined symbol i

12.

#include<stdio.h>

int main()

{

int a, b = 10;

a = -b--;

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

return 0;

}

a)

a = 10,b = 8

b)

a = 11,b = 7

c)

a = 12,b = 10

d)

a = -10, b = 9

13.

What will be the output of the following statements ?

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

printf("%d %d %D",x[3],x[2],x[1]);

a)

03%D

b)

000

c)

032

d)

321

14.

What will be the output of the following program ?

#include

void main()

{

int a = 36, b = 9;

printf("%d",a>>a/b-2);

}

a)

9

b)

7

c)

5

d)

None

15.

What would be the output of the following program?

#include

main()

{

char str[]="S\065AB";

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

}

a)

7

b)

6

c)

5

d)

Error

16.

What will be output if you will compile and execute the following c code?

struct marks{

int p:3;

int c:3;

int m:2;

};

void main(){

struct marks s={2,-6,5};

printf("%d %d %d",s.p,s.c,s.m);

}

a)

2 -6 5

b)

2 -6 1

c)

2 2 1

d)

Compile Error

17.

What will be output if you will compile and execute the following c code?

#define call(x) #x

void main(){

printf("%s",call(c/c++));

}

a)

c

b)

c++

c)

#c/c++

d)

c/c++

18.

What is output of below program?

int main()

{

int i,j,count;

count=0;

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

{

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

{

count++;

}

}

printf("%d",count);

return 0;

}

a)

55

b)

54

c)

1

d)

0

19.

What is output of below program?

int main()

{

int i,j,k,count;

count=0;

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

{

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

{

count++;

}

}

printf("%d",count);

return 0;

}

a)

5

b)

10

c)

25

d)

50

20.

What is output of below program?

int main()

{

int i,j;

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

{

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

}

return 0;

}

a)

0--01--12--23--34--

b)

00--10--20--30--40--

c)

Compile Error

d)

00--01--02--03--04--

21.

What is output of below program?

int main()

{

int i;

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

{

printf("Hello");

}

return 0;

}

a)

Hello is printed 5 times

b)

Compilation Error

c)

Hello is printed 2 times

d)

Hello is printed 3 times

22.

What is the output of below program?

int main()

{

int i;

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

{

printf("Hello");

}

return 0;

}

a)

Hello is printed 5 times

b)

Compile Error

c)

RunTime Error

d)

Hello is printed 4 times

23.

What is the output of below program?

int main()

{

for(; ;)

for(; ;)

printf("Hello..");

return 0;

}

a)

Compile Error

b)

RunTime Error

c)

Hello is printed infinite times

d)

Hello is printed one time

24.

(24)

What is output of below code?

int main()

{

char name[]="Cppbuz";

int len;

int size;

len = strlen(name);

size = size_of(name);

printf("%d,%d",len,size);

return 0;

}

a)

6,6

b)

6,7

c)

7,7

d)

7,6

25.

What is storage class for variable A in below code?

int main(){

int A;

A = 10;

printf("%d", A);

return 0;}

a)

extern

b)

auto

c)

register

d)

static

26.
Point out the error in the following program 
a)
No error
b)
display() doesn't get invoked
c)
display() is called before it is defined
d)
None of these
27.

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

28.

What will be the output of the following C code?

#include <stdio.h>

void main()

{

float x = 0.1;

printf("%d, ", x);

printf("%f", x);

}

a)

0.100000, junk value

b)

Junk value, 0.100000

c)

0, 0.100000

d)

0, 0.999999

29.

int x=1;

double y= 0.5 * (exp (x) + exp (-x));

a)

cos(x)

b)

cosh(x)

c)

fmod(x)

d)

modf(x)

30.

What will be the output of the following C code if the system time is 1:52 PM (Sunday)?

#include<stdio.h>

#include<time.h>

int main()

{

struct tm *ptr;

time_t t;

char str[100];

t = time(NULL);

ptr = localtime(&t);

strftime(str,100,"%I",ptr);

puts(str);

return 0;

}

a)

error

b)

01

c)

1

d)

13

31.

What is the meaning of the following C code if output is 0?

#include<stdio.h>

#include<time.h>

int main()

{

struct tm *local;

time_t t;

t=time(NULL);

local=localtime(&t);

printf("%d",local->tm_isdst);

return 0;

}

a)

DST is in effect

b)

DST status is unknown

c)

DST is not in effect

d)

DST is corresponding with local time

32.

What will be the output of the following C code?

#include <stdio.h>

void main()

{

register int x = 0;

if (x < 2)

{

x++;

main();

}

}

a)

Segmentation fault

b)

main is called twice

c)

main is called once

d)

main is called thrice

33.

What will be the output of the following C code?

#include <stdio.h>

struct point

{

int x;

int y;

};

void foo(struct point*);

int main()

{

struct point p1[] = {1, 2, 3, 4};

foo(p1);

}

void foo(struct point p[])

{

printf("%d\n", p[1].x);

}

a)

compile error

b)

1

c)

3

d)

2

34.

What will be the output of the following C code?

#include <stdio.h>

void main()

{

float x;

int y;

printf("enter two numbers \n");

scanf("%f %f", &x, &y);

printf("%f, %d", x, y);

}

a)

7.000000, 7

b)

Run time error

c)

7.000000, junk

d)

Varies

35.

What is the output of the following C code if there is no error in stream fp?

#include <stdio.h>

int main()

{

FILE *fp;

fp = fopen("newfile", "w");

printf("%d\n", ferror(fp));

return 0;

}

a)

Compilation error

b)

0

c)

1

d)

none

36.

What will be the output of the following C code?

#include <stdio.h>

int x = 0;

void main()

{

int *const ptr = &x;

printf("%p\n", ptr);

ptr++;

printf("%p\n ", ptr);

}

a)

0 1

b)

Compile time error

c)

0xbfd605e8 0xbfd605ec

d)

0xbfd605e8 0xbfd605e8

37.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

double ptr = (double )100;

ptr = ptr + 2;

printf("%u", ptr);

}

a)

115

b)

102

c)

116

d)

108

38.

Identify X library function for line input and output in the following C code?

#include <stdio.h>

int X(char s, FILE iop)

{

int c;

while (c = *s++)

putc(c, iop);

return ferror(iop) ? EOF : 0;

}

a)

getc

b)

putc

c)

fgets

d)

fputs

39.

What will be the output of the following C code?

#include <stdio.h>

#define foo(x, y) x / y + x

int main()

{

int i = -6, j = 3;

printf("%d\n",foo(i + j, 3));

return 0;

}

a)

Divided by zero exception

b)

Compile time error

c)

-8

d)

-4

40.

Which part of the program address space is p stored in the following C code?

#include <stdio.h>

int *p;

int main()

{

int i = 0;

p = &i;

return 0;

}

a)

Code/text segment

b)

Data segment

c)

Bss segment

d)

Stack

41.

What will be the output of the following C code?

#include <stdio.h>

int main()

{

int n;

scanf("%d", &n);

ungetc(n, stdin);

scanf("%d", &n);

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

return 0;

}

a)

Compile time error

b)

Whatever is typed by the user first time

c)

Whatever is typed by the user second time

d)

Undefined behaviour

42.

What will be the output of the following C code?

main()

{

enum resut {pass, fail};

enum result s1,s2;

s1=pass;

s2=fail;

printf("%d",s1);

}

a)

error

b)

fail

c)

pass

d)

0

43.

What will be the output of the following C code?

#include <stdio.h>

int (*(x()))[2];

typedef int (*(*ptr)())[2] ptrfoo;

int main()

{

ptrfoo ptr1;

ptr1 = x;

ptr1();

return 0;

}

int (*(x()))[2]

{

int (*ary)[2] = malloc(sizeof*ary);

return &ary;

}

a)

Compile time error

b)

Undefined behaviour

c)

Depends on the standard

d)

none

44.

Which of the following should be used for freeing the memory allocated in the following C code?

#include <stdio.h>

struct p

{

struct p *next;

int x;

};

int main()

{

struct p p1 = (struct p)malloc(sizeof(struct p));

p1->x = 1;

p1->next = (struct p*)malloc(sizeof(struct p));

return 0;

}

a)

free(p1);

free(p1->next)

b)

free(p1->next); free(p1);

c)

free(p1);

d)

all of the mentioned

45.

What will be the output of the following C code?

#include <stdio.h>

struct student

{

char *c;

struct student *point;

};

void main()

{

struct student s;

struct student m;

s.c = m.c = "hi";

m.point = &s;

(m.point)->c = "hey";

printf("%s\t%s\t", s.c, m.c);

}

a)

hey hi

b)

hi hey

c)

hey hey

d)

runtime error

46.

What will be the output of the following C code?

#include <stdio.h>

struct student

{

char *name;

};

void main()

{

struct student s, m;

s.name = "st";

m = s;

printf("%s%s", s.name, m.name);

}

a)

Nothing

b)

st st

c)

compile time erro

d)

junkvalue

47.

What will be the output of the following C code?

#include <stdio.h>

void main()

{

char *a[10] = {"hi", "hello", "how"};

int i = 0;

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

printf("%s", *(a[i]));

}

a)

segmentation fault

b)

hi hello how followed by 7 null values

c)

10 null values

d)

depends on compiler

48.

1.What will be the output of the following C code on a 32-bit system?

a)

10

b)

13

c)

run time error

d)

40

49.

2.What will be the output of the following C code?

a)

102

b)

104

c)

108

d)

116

50.

What will be the output of the following C code?

a)

str1 is not greater than str2

b)

str2 is not greater than str1

c)

both are equal

d)

error in given code

51.

What will be the output of the following C code?

a)

6 7

b)

6 6

c)

5 5

d)

5 6

52.

What will the following C code do?

a)

find last occurrence of c in char s[ ].

b)

find first occurrence of c in char s[ ].

c)

find the current location of c in char s[ ].

d)

There is error in the given code

53.

What will be the output of the following C code?

a)

Compilation error

b)

1 2 3

c)

1 2

d)

1 3

54.

What will be the output of the following C code? (Assuming that we have entered the value 1 in the standard input)

a)

1

b)

compile error

c)

2

d)

run time error

55.

What will be the output of the following C code?

a)

Loop Loop

b)

Compilation error

c)

Loop Loop Loop Loop

d)

Infinite Loop

56.

What will be the output of the following C code? (Assuming size of int be 4)

a)

4

b)

12

c)

16

d)

Can’t be estimated due to ambiguous initialization of array

57.

What will be the output of the following C code?

a)

i value is 1 and j value is 1

b)

i value is 0 and j value is 0

c)

i value is 1 and j value is undefined

d)

i and j value are undefined

58.

What will be the output of the following C code?

a)

37

b)

Compile time error

c)

Varies

d)

Depends on compiler

59.

The correct syntax to access the member of the ith structure in the array of structures is?

a)

s.b.[i];

b)

s.[i].b;

c)

s.b[i];

d)

s[i].b;

60.

What will be the output of the following C code?

a)

1 2 3 4 5

b)

1 2 3 4

c)

Compile time error

d)

Stack overflow

61.

What will be the output of the following C code?

a)

9

b)

11

c)

12

d)

21

62.

What will be the output of the following C code?

a)

Compile time error

b)

Varies

c)

hi

d)

h

63.

Which option should be selected to work the following C expression?  

a)

typedef char [] string;

b)

typedef char *string;

c)

typedef char [] string; and typedef char *string;

d)

Such expression cannot be generated in C

64.

What will be the output of the following C code?

a)

segmentation fault

b)

hi hello how followed by 7 null values

c)

10 null values

d)

depends on compiler

65.

What will be the output of the following C code? (Assuming that we have entered the value 2 in the standard input)

a)

1

b)

hi 2

c)

Run time error

d)

2

66.

What will be the output of the following C code?

a)

h e

b)

e l

c)

h h

d)

e e

67.

What will be the output of the following C code?

a)

Nothing

b)

0

c)

Compile time error

d)

Junkvalue

68.

What is the Output ?

a)

21

b)

5

c)

13

d)

111

69.

What is the Output ?

a)

3.000

b)

3

c)

3.5

d)

3.500

70.

In C '&' used in 'scanf' represents

a)

For separating input data

b)

Pointer to variable

c)

Memory Location

d)

And operator

71.

What is the Output ?

a)

6 6 2

b)

12 0 3

c)

Runtime Error

d)

Compilation Error

72.

'Continue' statement is used to ?

a)

To stop program execution

b)

To go next line

c)

To Stop Current iteration and start next iteration

d)

To run infinite loop

73.

An Array is initialized with size 20 in c. if first element location is at 1940(memory address), what will the location of 11th element?

(size of int = 2bytes)

a)

1961

b)

1960

c)

1950

d)

1951

74.

what does following code do??

a)

Makes the Given Matrix Symmetric

b)

Transpose the Matrix

c)

Matrix Multiplication

d)

None of this

75.

What is the Output?

a)

prints "Hello World"

b)

prints "Hello World" 5 times in same line

c)

prints "Hello World" 5 times in multiple line

d)

prints "0"

76.

What is the Value of "256>>1"

a)

25

b)

128

c)

257

d)

256

77.

first and second term in geometric progression are 3 and 6 find common ratio?

a)

9

b)

2

c)

3

d)

18

78.

What is (void*)0?

a)

Representation of void pointer

b)

Representation of NULL pointer

c)

Error

d)

Representation of int pointer

79.

What will be the output of the following C code?

a)

2 3

b)

2 garbagevalue

c)

Error

d)

2 4

80.

What is the Average and Worst time complexities of Binary Search Algorithm

a)

O(1) , O(1)

b)

O(log n) , O(log n)

c)

O(1) , O(log n)

d)

O(log n) , O(n)

81.

Average time Complexity of Merge Sort?

a)

O(n log n)

b)

O(n^2)

c)

O(n)

d)

O(log n)

82.

What is Output ?

a)

P

b)

o

c)

Coding Club

d)

oding Club

83.

Which type of pointer is a most convention way of storing raw address in c programming?

a)

Void Pointer

b)

Double Pointer

c)

Null Pointer

d)

Integer Pointer

84.

Among 4 header files, which should be included to use the memory allocation functions like malloc(), calloc(), realloc() and free()?

a)

<string.h>

b)

<memory.h>

c)

<stdlib.h>

d)

Both

<memory.h>

<stdlib.h>

85.

What is the return type of malloc() or calloc()?

a)

int *

b)

int **

c)

void *

d)

void **

86.

What is output?

a)

100

b)

Compilation Error

c)

0

d)

Garbage Valur

87.

What is Output ?

a)

-1

b)

0

c)

1

d)

Compilation Error

88.

In C File is a type of?

a)

int

b)

char *

c)

struct

d)

void

89.

If an error occurs, the function fseek() will returns

a)

-1

b)

NULL

c)

non-zero value

d)

0

90.

What is Output ?

a)

14

b)

13

c)

12

d)

11

91.

What is the output ?

a)

Error

b)

i = 1

c)

i = 16

d)

i = 0

92.

What is output ?

a)

1

b)

6

c)

3

d)

Error

93.

what is Output ?

a)

3 3 1 3 1

b)

3 3 1 3 0

c)

Garbage Values

d)

Error

94.

What is the Output ?

a)

Compilation Error

b)

Runtime Error

c)

False

d)

True

95.

How many times is Hello world printed ?

a)

1

b)

4

c)

2

d)

8

96.

What is output?

a)

print i till 9 and j till 19

b)

print i and j till 19

c)

print i and j till 9

d)

Error

97.

The operators (. , !! , < , = )

Ascending order of precedence is?

a)

. !! < =

b)

< !! = .

c)

= < !! .

d)

= !! < .

98.

What will be the output of the code? #include int main() { int a = 5, b = 10; a = a + b; b = b - a; a = a - b; printf("a = %d, b = %d\n", a, b); return 0; }

a)

10

b)

15

c)

5

d)

20

99.

How many times the while loop will get executed if a short int is 2 byte wide? #include int main() { int j=1; while(j <= 255) { printf("%c %d\n", j, j); j++; } return 0; }

a)

Infinite times

b)

255 times

c)

256 times

d)

254 times

100.

Which of the following errors would be reported by the compiler on compiling the program given below? #include int main() { int a = 5; switch(a) { case 1: printf("First"); case 2: printf("Second"); case 3 + 2: printf("Third"); case 5: printf("Final"); break; } return 0; }

a)

There is no break statement in each case.

b)

Expression as in case 3 + 2 is not allowed.

c)

Duplicate case case 5:

d)

No error will be reported.

101.

Point out the error, if any in the program. #include int main() {int P = 10; switch(P) { case 10: printf("Case 1"); case 20: printf("Case 2"); break; case P: printf("Case 2"); break; } return 0; }

a)

Error: No default value is specified

b)

Error: Constant expression required at line case P:

c)

Error: There is no break statement in each case.

d)

No error will be reported.

102.

What will be the output of the program? #include int main() { int i=2; printf("%d, %d\n", ++i, ++i); return 0; }

a)

3, 4

b)

4, 3

c)

4, 4

d)

Output may vary from compiler to compiler

103.

How many times the program will print "SMTEC" ? #include int main() { printf("SMTEC"); main(); return 0; }

a)

Infinite times

b)

32767 times

c)

65535 times

d)

Till stack overflows

104.

What will be the output of the program? #include #define SQR(x)(x*x) int main() { int a, b=3; a = SQR(b+2); printf("%d\n", a); return 0; }

a)

25

b)

11

c)

Error

d)

Garbage value

105.

What will be the output of the program ? #include int main() { char *p; p="hello"; printf("%s\n", *&*&p); return 0; }

a)

llo

b)

hello

c)

ello

d)

h

106.

What will be the output of the program? #include int main() { int i=-3, j=2, k=0, m; m = ++i && ++j && ++k; printf("%d, %d, %d, %d\n", i,j, k, m); return 0; }

a)

-2, 3, 1, 1

b)

2, 3, 1, 2

c)

1, 2, 3, 1

d)

3, 3, 1, 2

107.

What will be the output of the program ? #include #include int main() { char str[] = "India\0\SMTEC\0"; printf("%s\n", str); return 0; }

a)

SMTEC

b)

India

c)

India SMTEC

d)

India\0SMTEC

108.

What will be the output of the program ? #include int main() { void *vp; char ch=74, *cp="JACK"; int j=65; vp=&ch; printf("%c", *(char*)vp); vp=&j; printf("%c", *(int*)vp); vp=cp; printf("%s", (char*)vp+2); return 0; }

a)

JCK

b)

J65K

c)

JAK

d)

JACK

109.

Point out the error, if any in the program. #include int main() { int a = 10, b; a >=5 ? b=100: b=200; printf("%d\n", b); return 0; }

a)

100

b)

200

c)

Error: L value required for b

d)

Garbage value

110.

Which of the following statements are correct about the program? #include int main() { int x = 30, y = 40; if(x == y) printf("x is equal to y\n"); else if(x > y) printf("x is greater than y\n"); else if(x < y) printf("x is less than y\n") return 0; }

a)

Error: Statement missing

b)

Error: Expression syntax

c)

Error: Lvalue required

d)

Error: Rvalue required

111.

What will be the output of the program? #include int main() { int i=4, j=-1, k=0, w, x, y, z; w = i || j || k; x = i && j && k; y = i || j &&k; z = i && j || k; printf("%d, %d, %d, %d\n", w, x, y, z); return 0; }

a)

1, 1, 1, 1

b)

1, 1, 0, 1

c)

1, 0, 0, 1

d)

1, 0, 1, 1

112.

Point out the error in the program f(int a, int b) { int a; a = 20; return a; }

a)

Missing parenthesis in return statement

b)

The function should be defined as int f(int a, int b)

c)

Redeclaration of a

d)

None of above

113.

What will be the output of the program ? #include #include int main() { char str1[20] = "Hello", str2[20] = " World"; printf("%s\n", strcpy(str2, strcat(str1, str2))); return 0; }

a)

Hello

b)

World

c)

Hello World

d)

WorldHello

114.

To scan a and b given below, which of the following scanf() statement will you use? #include float a; double b;

a)

scanf("%f %f", &a, &b);

b)

scanf("%Lf %Lf", &a, &b);

c)

scanf("%f %Lf", &a, &b);

d)

scanf("%f %lf", &a, &b);

115.

What will be the output of the program? #include int main() { unsigned int res; res = (64 >>(2+1-2)) & (~(1<<2)); printf("%d\n", res); return 0; }

a)

32

b)

64

c)

0

d)

128

116.

Which of the following is the correct order of evaluation for the below expression? z = x + y * z / 4 % 2 - 1

a)

* / % + - =

b)

= * / % + -

c)

/ * % - + =

d)

* % / - + =

117.

What will be the output of the program? #include #include int main() { int i=0; i++; if(i<=5) { printf("SMTEC"); exit(1); main(); } return 0; }

a)

Prints "SMTEC" 5 times

b)

Function main() doesn't calls itself

c)

Infinite loop

d)

Prints "SMTEC"

118.

What will be the output of the program ? #include int main() { int a = 5, b = 10; a = a * b; b = b / a; printf("%d\n", b); return 0; }

a)

0

b)

1

c)

2

d)

5

119.

What will be the output of the program ? #include int main() { char str1[20] = "Hello", str2[20] = "World"; strcat(str1, str2); printf("%s\n", str1); return 0; }

a)

Hello

b)

HelloWorld

c)

WorldHello

d)

Error

120.

How many times will the for loop execute? #include int main() { for(int i = 0; i < 10; i++) { printf("%d ", i); } return 0; }

a)

9 times

b)

10 times

c)

11 times

d)

Infinite times

121.

What will be the output of the program ? #include int main() { int a = 10, b = 5; a = a / b; b = a + b; printf("%d\n", b); return 0; }

a)

2

b)

5

c)

10

d)

15

122.

What will be the output of the program ? #include int main() { int arr[5] = {1, 2, 3, 4, 5}; printf("%d\n", arr[2]); return 0; }

a)

1

b)

2

c)

3

d)

4

123.

What will be the output of the code? #include int main() { int a = 5, b = 10; a = a + b; b = b - a; a = a - b; printf("a = %d, b = %d\n", a, b); return 0; }

4 lines
124.

Debug the code #include int main() { int a = 2; switch (a) { case 1: printf("One\n"); case 2: printf("Two\n"); case 3: printf("Three\n"); default: printf("Default\n"); } return 0; }

4 lines
125.

What will be the output of the code? #include int main() { int a = 257; char b = a; printf("b = %d\n", b); return 0; }

4 lines
126.

Fix the error #include int main() { int x = 10, y = 0; printf("%d", x / y); return 0; }

4 lines
127.

What will be the output of the code? #include int main() { int a = 5, b = 2; int result = a + b * 3; printf("Result = %d\n", result); return 0; }

4 lines
128.

Identify the issue with this code and suggest a fix. #include int main() { int i = 1; while (i <= 10); { printf("%d ", i); i++; } return 0; }

4 lines
129.

What will be the output of the code? #include int main() { int x = 5; printf("%d ", x++); printf("%d ", ++x); printf("%d\n", x--); return 0; }

4 lines
130.

Identify the error with the code #include int main() { int a = 10; if (a = 20) { printf("a is 20\n"); } return 0; }

4 lines
131.

Debug the code #include int main() { int a = 5.7; printf("a = %d\n", a); return 0; }

4 lines
132.

What will be the output? #include int main() { for (int i = 0; i < 5; i++) { if (i == 3) { continue; } printf("%d ", i); } return 0; }

4 lines
133.

Identify the error and correct it in the code below: int main() { int* ptr; *ptr = 20; printf("%d\n", *ptr); return 0; }

4 lines
134.

Find and fix the issue: int main() { int a = 10; int* ptr; ptr = a; printf("%d\n", *ptr); return 0; }

4 lines
135.

Debug and fix it int main() { int arr[5]; for (int i = 0; i < 5; i++) { printf("%d ", arr[i]); } return 0; }

4 lines
136.

What will be the output of the program? #include int main() { int k, num=30; k = (num>5 ? (num <=10 ? 100 : 200): 500); printf("%d\n", num); return 0; }

a)

200

b)

30

c)

100

d)

500

137.

Which of the following statements are correct about the below C-program? #include int main() { int x = 10, y = 100%90, i; for(i=1; i<10; i++) if(x != y); printf("x = %d y = %d\n", x, y); return 0; }

a)

The printf() function is called 10 times.

b)

The program will produce the output x = 10 y = 10

c)

The ; after the if(x!=y) will NOT produce an error.

d)

The program will not produce output.

138.

What will be the output of the program? #include int main() { int k, num=30; k = (num>5 ? (num <=10 ? 100 : 200): 500); printf("%d\n", num); return 0; }

a)

200

b)

30

c)

100

d)

500

139.

Which of the following statements are correct about the function? long fun(int num) { int i; long f=1; for(i=1; i<=num; i++) f = f * i; return f; }

a)

The function calculates the value of 1 raised to power num.

b)

The function calculates the square root of an integer

c)

The function calculates the factorial value of an integer

d)

None of above

140.

Which of the statements is correct about the program? #include int main() { float a=3.14; char *j; j = (char*)&a; printf("%d\n", *j); return 0; }

a)

It prints ASCII value of the binary number present in the first byte of a float variable a.

b)

It prints character equivalent of the binary number present in the first byte of a float variable a.

c)

It will print 3

d)

It will print a garbage value

141.

Will the program compile in Turbo C? #include int main() { int a=10, *j; void *k; j=k=&a; j++; k++; printf("%u %u\n", j, k); return 0; }

a)

Yes

b)

No

142.

Which of the following statements are correct about an array? 1: The array int num[26]; can store 26 elements. 2: The expression num[1] designates the very first element in the array. 3: It is necessary to initialize the array at the time of declaration. 4: The declaration num[SIZE] is allowed if SIZE is a macro.

a)

1

b)

1,4

c)

2,3

d)

2,4

143.

If char=1, int=4, and float=4 bytes size, What will be the output of the program ? #include int main() { char ch = 'A'; printf("%d, %d, %d", sizeof(ch), sizeof('A'), sizeof(3.14f)); return 0; }

a)

1, 2, 4

b)

1, 4, 4

c)

2, 2, 4

d)

2, 4, 8

144.

What will be the output of the program ? #include int main() { char str[] = "Nagpur"; str[0]='K'; printf("%s, ", str); str = "Kanpur"; printf("%s", str+1); return 0; }

a)

Kagpur, Kanpur

b)

Nagpur, Kanpur

c)

Kagpur, anpur

d)

Error

145.

What will be the output of the program ? #include int main() { int i=4, j=8; printf("%d, %d, %d\n", i|j&j|i, i|j&j|i, i^j); return 0; }

a)

12, 12, 12

b)

112, 1, 12

c)

32, 1, 12

d)

-64, 1, 12

146.

What is the output of the program? typedef struct data; { int x; sdata *b; }sdata;

a)

Error: Declaration missing ';'

b)

Error: in typedef

c)

No error

d)

None of above

147.

How many times "IndiaBIX" is get printed? #include int main() { int x; for(x=-1; x<=10; x++) { if(x < 5) continue; else break; printf("SMTEC"); } return 0; }

a)

A.Infinite times

b)

B.11 times

c)

C. 0 times

d)

D. 10 times

148.

What will be the output of the program? #include int main() { int i=-3, j=2, k=0, m; m = ++i && ++j || ++k; printf("%d, %d, %d, %d\n", i, j, k, m); return 0; }

a)

A.1, 2, 0, 1

b)

B.-3, 2, 0, 1

c)

C.-2, 3, 0, 1

d)

D.2, 3, 1, 1

149.

What will be the output of the program? #include int addmult(int ii, int jj) { int kk, ll; kk = ii + jj; ll = ii * jj; return (kk, ll); } int main() { int i=3, j=4, k, l; k = addmult(i, j); l = addmult(i, j); printf("%d, %d\n", k, l); return 0; }

a)

12, 12

b)

7, 7

c)

7, 12

d)

12, 7

150.

Will the following program print the message infinite number of times? #include #define INFINITELOOP while(1) int main() { INFINITELOOP printf("SMTEC"); return 0; }

a)

Yes

b)

No

151.

If the size of integer is 4bytes, What will be the output of the program? #include int main() { int arr[] = {12, 13, 14, 15, 16}; printf("%d, %d, %d\n", sizeof(arr), sizeof(*arr), sizeof(arr[0])); return 0; }

a)

A.10, 2, 4

b)

B.20, 4, 4

c)

C.16, 2, 2

d)

D.20, 2, 2

152.

What will be the output of the program ? #include int *check(static int, static int); int main() { int *c; c = check(10, 20); printf("%d\n", c); return 0; } int *check(static int i, static int j) { int *p, *q; p = &i; q = &j; if(i >= 45) return (p); else return (q); }

a)

10

b)

20

c)

Error: Non portable pointer conversion

d)

Error: cannot use static for function parameters

153.

What will be the output of the program if the array begins at address 65486? #include int main() { int arr[] = {12, 14, 15, 23, 45}; printf("%u, %u\n", arr, &arr); return 0; }

a)

A.65486, 65488

b)

B.65486, 65486

c)

C.65486, 65490

d)

D.65486, 65487

154.

What will be the output of the program? #include int main() { int a = 5, b = 10; printf("%d, %d\n", a + b, a * b); return 0; }

a)

15, 50

b)

15, 15

c)

10, 10

d)

5, 5

155.

What will be the output of the program? #include int main() { int x = 0; while(x < 5) { printf("%d ", x); x++; } return 0; }

a)

0 1 2 3 4

b)

1 2 3 4 5

c)

0 1 2 3 4 5

d)

5

156.

What will be the output of the program? #include int main() { int arr[3] = {1, 2, 3}; printf("%d, %d\n", arr[0], arr[1]); return 0; }

a)

1, 2

b)

2, 3

c)

1, 3

d)

0, 0

157.

What will be the output of the program? #include int main() { int x = 0; while(x < 3) { printf("%d ", x); x++; } return 0; }

a)

0 1 2

b)

1 2 3

c)

0 1 2 3

d)

3

158.

Which of the following statements is true about the program? #include int main() { int arr[5] = {1, 2, 3, 4, 5}; printf("%d\n", arr[2]); return 0; }

a)

It prints 3

b)

It prints 2

c)

It prints 5

d)

It prints 1

159.

What will be the output of the program? #include int main() { int x = 1; if(x) { printf("True\n"); } else { printf("False\n"); } return 0; }

a)

True

b)

False

160.

What will be the output of the program? #include int main() { int arr[3] = {1, 2, 3}; printf("%d, %d\n", arr[1], arr[2]); return 0; }

a)

1, 2

b)

2, 3

c)

1, 3

d)

0, 0