0% found this document useful (0 votes)
218 views

C Language Questions

The document contains 21 multiple choice questions about C programming concepts like loops, functions, operators, data types etc. Each question is followed by 4 possible answer choices. The questions cover a variety of basic and some advanced C programming topics to test knowledge of the C language.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
218 views

C Language Questions

The document contains 21 multiple choice questions about C programming concepts like loops, functions, operators, data types etc. Each question is followed by 4 possible answer choices. The questions cover a variety of basic and some advanced C programming topics to test knowledge of the C language.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 55

C LANGUAGE Page 1

Version 1.0 Revision Date: 30/08/08

C QUESTION BANK 1

1.What would be the output of the program

main(){
unsigned int i;
for(i=1;i>-2;i--)
printf("c aptitude");
}

a. c aptitude

b. Nothing will print

c. Infinite loop

d. None of these

2. What would be the output of the program

main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}.
a.Stack overflow
b.5 4 3 2 1
c.5 5 5 5 5

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 2

Version 1.0 Revision Date: 30/08/08

d.None of these

3. What would be the output of the program

main()

float i=1.5;

switch(i)

case 1: printf("1");

case 2: printf("2");

default : printf("0");

a. 1
b. 1 2 0
c. Compiler error
d. None of these

4. What would be the output of the program

main()

register int a=2;

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 3

Version 1.0 Revision Date: 30/08/08

printf("Address of a = %d",&a);

printf("Value of a = %d",a);

a. Runtime error
b. Compiler error
c. Code will execute
d. None of these

5. What would be the output of the program

void main( )

int i;

i=(2,3);

printf("%d",i);

a) 3

b) 2

c) garbage value.

d)none of these.

6. What would be the output of the program

#define count 100

main()

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 4

Version 1.0 Revision Date: 30/08/08

#define count 200

printf("%d",count);

a. Compiler error
b. 100
c. 200
d. None of these

7. What would be the output of the program

main()

int *p=(int*)malloc(-1);

printf("%d",p);

a. Starting address of allocated block


b. NULL
c. Compiler error
d. None of these

8. What would be the output of the program

main()

enum week (sun=1,mon=-1,tue};

printf("%d %d %d",sun,mon,tue);

a. compiler error

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 5

Version 1.0 Revision Date: 30/08/08

b. 1 -1 1

c. 0 1 2

d. none of these

9. What would be the output of the program

main()

int a=9;

if(a<10)

printf("hello");

printf("world");

else

printf("HELLO WORLD");

a. compiler error

b. HELLO WORLD

c. hello

d. hello world

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 6

Version 1.0 Revision Date: 30/08/08

10. What would be the output of the program

main()

char j;

for(j=1;100;j++)

printf("%d",j);

a. compiler error

b. infinte loop

c. nothing will print

d. none of these

11. What would be the output of the program

void f(char *a)

if(a[0]=='\0')

return ;

f(a+1);

f(a+1);

printf("%c",a[0]);

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 7

Version 1.0 Revision Date: 30/08/08

main()

f("ABC");

a.CCBCCBA

b.compiler error

c.CCBCCB

d.none of these

12. What would be the output of the program

main()

int num=1;

while(num<=5)

printf("%d",num);

if(num<2)

goto here;

num++;

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 8

Version 1.0 Revision Date: 30/08/08

fun()

here:

printf("PP");

a. 1 PP

b. compiler error

c. nothing will print

d. none of these

13. What would be the output of the program

main()

#define x 10

printf("%d",x++);

a. 10

b. 11

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 9

Version 1.0 Revision Date: 30/08/08

c. compiler error

d. none of these

13. What would be the output of the program

main()

printf("hello"):

main();

a. Hello
b. Stack overflow
c. Hello will print infinite times
d. None of these

14. What would be the output of the program

main()

const int x;

x=100;

printf("%d",x);

a. 100

b. runtime error

c. compiler error

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 10

Version 1.0 Revision Date: 30/08/08

d. none of these

15.
main()

char *p="GOOD";

char a[ ]="GOOD";

printf("\n sizeof(p) = %d, sizeof(*p) = %d, strlen(p) =


%d", sizeof(p), sizeof(*p), strlen(p));

printf("\n sizeof(a) = %d, strlen(a) = %d", sizeof(a),


strlen(a));

a.4 1 4 5 4

b.4 4 4 5 4

c.compiler error

d.none of these

16.

main()

extern i;

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

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 11

Version 1.0 Revision Date: 30/08/08

int i=20;

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

a.runtime error

b.compiler error

c.20

d.none of these

17.

main()

int i=5,j=10;

i=i&=j&&10;

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

a.1 10

b.10 1

c.compiler error

d.none of these

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 12

Version 1.0 Revision Date: 30/08/08

18.

main()

int i = 3;

for (;i++=0;) printf(%d,i);

a.i value will print

b.compiler error

c.runtime error

d.none of these

19.

main()

char p[ ]="%d\n";

p[1] = 'c';

printf(p,65);

a.compiler error

b.runtime error

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 13

Version 1.0 Revision Date: 30/08/08

c.A

d.none of these

20.

main()

int i=5;

printf(%d,i=++i ==6);

a.1

b.compiler error

c.runtime error

d.none of these

21.

main()
{
int i=5;
printf("%d",++i++);
}
a.runtime error
b.7
c.compiler error

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 14

Version 1.0 Revision Date: 30/08/08

d.none of these
22.

main()

char i=0;

for(;i>=0;i++) ;

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

a.no output

b.compiler error

c.-128

d.none of these

23.

main()

unsigned int i=65000;

while(i++!=0);

printf("%d",i);

a. compiler error

b. runtime error

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 15

Version 1.0 Revision Date: 30/08/08

c.infinite loop

d.none of these

24.

void main()

static int i=5;

if(--i){

main();

printf("%d ",i);

a.5 4 3 2 1

b.stack overflow

c.runtime error

d.0 0 0 0

25.

main(){
int a= 0;int b = 20;char x =1;char y =10;
if(a,b,x,y)
printf("hello");
}

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 16

Version 1.0 Revision Date: 30/08/08

a.compiler error
b.hello
c.nothing will print
d.none of these

26.
main()
{
int i=-1;
-i;
printf("i = %d, -i = %d \n",i,-i);
}
a.1 -1
b compiler error
c.-1 1
d.none of these
27.

main()
{
char not;
not=!2;
printf("%d",not);
}
a.0
b.1
c.error
d.none of these

28.
main()

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 17

Version 1.0 Revision Date: 30/08/08

{
main();
}
a.Compiler error
b.stack overflow
c.nothing will happen
d.none of these
29.
main()
{
show();
}
void show()
{
printf("I'm the greatest");
}
a.compiler error
b.runtime error
c.Im greatest
d.none of these
30.

main()
{
int i=0;

for(;i++;printf("%d",i)) ;
printf("%d",i);
}
a.compiler error
b.nothing will print

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 18

Version 1.0 Revision Date: 30/08/08

c.1
d.none of these
31.

main()
{
int i;
printf("%d",scanf("%d",&i)); // value 10 is given as input
here
}
a. 1
b. 10
c. Compiler error
d. None of these
32.

#include<stdio.h>
main()
{
int i=1,j=2;
switch(i)
{
case 1: printf("GOOD");
break;
case j: printf("BAD");
break;
}
}
a. Compiler error
b. GOOD
c. BAD

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 19

Version 1.0 Revision Date: 30/08/08

d. None of these

33.

main()
{
int i=1;
while (i<=5)
{
printf("%d",i);
if (i>2)
goto here;
i++;
}
}
fun()
{
here:
printf("PP");

}
a.pp
b.compiler error
c.runtime error
d.none of these
34.

#include <stdio.h>
#define a 10
main()
{

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 20

Version 1.0 Revision Date: 30/08/08

#define a 50
printf("%d",a);
}
a.10
b.50
c.error
d.none of these
35.
#define square(x) x*x
main()
{
int i;
i = 64/square(4);
printf("%d",i);
}
a.1
b.error
c.64
d.none of these
36.
main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
}
a. hai
b. absiha
c. error
d. none of these

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 21

Version 1.0 Revision Date: 30/08/08

37.
#define int char
main()
{
int i=65;
printf("sizeof(i)=%d",sizeof(i));
}
a.1
b.4
c.error
d.none of these
38.
main()
{
printf("%x",-1<<4);
}
a. error
b. fffffff0
c. -16
d. None of these
39.
main()
{
int i=3;
switch(i)
{
default: printf("zero");
case 1: printf("one");
break;
case 2: printf("two");

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 22

Version 1.0 Revision Date: 30/08/08

break;
case 3: printf("three");
break;
}
}
a.three
b.three zero
c.error
d.none of these
40.
main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}
a.5 5 5 5 5
b.5 4 3 2 1
c.stack overflow
d.none of these

41.
main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I love U");
else

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 23

Version 1.0 Revision Date: 30/08/08

printf("I hate U");


}
a. I love u
b. I hate u
c. Nothing will print
d. None of these
42.
main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
a. Mmmm aaaa nnnn
b. Error
c. Mmm aaa nnn
d. None of these

43.
void main()
{
int const * p=5;
printf("%d",++(*p));
}
a.6
b.compile time error
c.runtime error
d.none of these
44.

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 24

Version 1.0 Revision Date: 30/08/08

main()
{
unsigned int x = 0xffff;
~x;
printf ("%x", x);
}
a.ffff
b.0
c.error
d.none of these
45.
main()
{
printf ("Hermione" "Granger");
}
a. error
b. HermioneGranger
c.runtime error
d.none of these
46.
main()
{
printf(%c,abcdefg[5]);
}
a.e
b.f
c.error
d.none of these

47.

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 25

Version 1.0 Revision Date: 30/08/08

What will be the value of z

main()

int z,x=5,y=-10,a=4,b=2;
z = x++ - --y * b / a;
}
a.5
b.6.
c.10
d.none of these

48.

main()

int a=10,b;

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

a. 12,10,11,13
b. 22,11,11,11
c. 12,11,11,11
d. 22,13,13,13

49.

main()

{
int x[] = { 1, 4, 8, 5, 1, 4 };

int *ptr, y;

ptr = x + 4;
y = ptr - x;
}

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 26

Version 1.0 Revision Date: 30/08/08

a. -3
b. 0
c. 4
d. None of these
50.

void myFunc (int x)

if (x > 0)

myFunc(--x);

printf("%d, ", x);

int main()

myFunc(5);

return 0;
}
a. 1, 2, 3, 4, 5, 5,
b. 4, 3, 2, 1, 0, 0,
c. 5, 4, 3, 2, 1, 0,
d. 0, 0, 1, 2, 3, 4,
51.
What is the value of myArray[1][2]; in the sample code above?

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 27

Version 1.0 Revision Date: 30/08/08

main()

int i,j;

int ctr = 0;

int myArray[2][3];

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

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

myArray[j][i] = ctr;

++ctr;
}
}
}
a. 1
b. 2
c. 3
d. 5

52.

main()

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 28

Version 1.0 Revision Date: 30/08/08

int m = -14;

int n = 6;

int o;

o = m % ++n;

n += m++ - o;

m <<= (o ^ n) & 3;

printf("%d %d %d",m,n,o);
}
a. m = -26, n = -7, o = 0
b. m = -52, n = -4, o = -2
c. m = -26, n = -5, o = -2
d. none of these

53.

char *buffer = "0123456789";

char *ptr = buffer;

ptr += 5;

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


printf( "%s\n", buffer );

a. 56789

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 29

Version 1.0 Revision Date: 30/08/08

0123456789
b.error
c.6 7 8 9
0123456789
d.none of these
54.

main()

int y[4] = {6, 7, 8, 9};

int *ptr = y + 2;

printf("%d\n", ptr[ 1 ] );

}
a.6
b.7
c.8
d.9
55.

main()

{int x = 0;

for ( ; ; )

if (x++ == 4)

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 30

Version 1.0 Revision Date: 30/08/08

break;

continue;

}
printf("x=%d\n", x);
}
a.4
b.5
c.0
d.none of these
56.

main()

char *ptr;

char myString[] = "abcdefg";

ptr = myString;

ptr += 5;

printf("%s",ptr);
}
a. fg
b. efg
c. defg
d. cdefg
57.

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 31

Version 1.0 Revision Date: 30/08/08

main() {

char *ch1="rajesh";

char *ch2;

ch2=(char*)malloc(20);

memset (ch2, 0, 20);

while(*ch2++ = *ch1++);

printf("%s\n",ch2);
}
a. rajesh
b. empty string
c. error
d. none of these
58.

main(){

int x=5;

printf("%d,%d,%d\n",x,x<<2,x>>2);
}
a. 5 20 5
b. 5 20 1
c. Error
d. None of these
59.

main()

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 32

Version 1.0 Revision Date: 30/08/08

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

int *ptr=(int*)(&a+1);

printf("%d %d",*(a+1),*(ptr-1));
}
a. 2 2
b. 2 1
c. 2 5
d. None of these
60.

main()

int i=3;

int j;

j=sizeof(++i + ++i);

printf("i %d j %d",i,j);
}
a. 4 2
b. 3 2
c. 3 4
d. 3 6
61.

main()

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 33

Version 1.0 Revision Date: 30/08/08

char a[]="abcde";

char *p=a;

p++;

p++;

p[2]='z';

printf("%s",p);
}
a.cde
b.zde
c.cdz
d. abzec
62.

main()

char *p;

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

p=(buf+1)[5];

printf("%d",p);
}
a. 5
b. 6

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 34

Version 1.0 Revision Date: 30/08/08

c. 9
d. None of these

63.

main()

printf("ABCDE"+sizeof("ABC"));

a. D
b. Error

c. E

d. ABCDE

64.

main()

int a[2];

a[1]=3;

printf("a[1] %d",a[1]);

printf("1[a] %d",1[a]);

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 35

Version 1.0 Revision Date: 30/08/08

a. 3 3
b. 3 0

c. Error

d. None of these

65.

main()

int i=300;

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

a. 300
b. 44

c. 256

d. None of the above

66.

main()

static int a[2][3]={{1,2,3},{4,5,6}};

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

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 36

Version 1.0 Revision Date: 30/08/08

a. 8
b. 3

c. 6

d. Error

67.

main()

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

a. Float
b. Double

c. Long double

d. Int

68.

main()

float va=3/2.0+1/2;

printf("%.3f",va);

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 37

Version 1.0 Revision Date: 30/08/08

a. 1.500
b. 2.000

c. 0.500

d. None of these

69.

main()

float a[3];

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

printf("%d",sizeof(&a));

a. 12 4
b. 4 12

c. Error

d. None of these

70.

main()

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 38

Version 1.0 Revision Date: 30/08/08

int sum;

enum temp{A,B,C=5,D,E};

sum =A+B+C+D+E;

printf("%d",sum);

a. 20
b. 19

c. 15

d. None of these

71.

main()

static a[3]={1};

int b[3]={1};

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

a. 1 1
b. 0 undefined

c. 0 0

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 39

Version 1.0 Revision Date: 30/08/08

d. Undefine undefined

72.

main()

int i=10;

i=!i>14;

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

a. 10
b. 0

c. Error

d. None of these

73.
#define f(g,g2) g##g2
main()
{
int var12=100;
printf("%d",f(var,12));
}

a. 100
b. Error

c. 10012

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 40

Version 1.0 Revision Date: 30/08/08

d. None of these

74.

main()
{
extern int i;
i=20;
printf("%d",sizeof(i));
}

a. Error
b. 4

c. Nothing will print

d. None of these

75.
main()

char *p;

p="%d\n";

p++;

p++;

printf(p-2,300);

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 41

Version 1.0 Revision Date: 30/08/08

a. Error
b. 300

c. Nothing will print

d. None of these

76.

What would be the output of the following program.


#include<stdio.h>
main()
{
extern int a;
printf("%d",a);;
}
int a=20;

a. 20

b. 0

c. garbage value

d. error!!

77.

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 42

Version 1.0 Revision Date: 30/08/08

main()
{
int i = -3, j = 2 , k = 0,m;
m = ++i && ++j || ++k;
printf("\n %d %d %d %d",i,j,k,m);
}
a. -2 3 0 1
b. -3 2 0 1
c. -2 3 1 1
d. error

78.
What would be the output of the following program.
#define CUBE(x) (x*x*x)
main()
{
int a, b=3;
a=CUBE(b++);
printf ("\n %d %d", a , b);
}

a.64 4
b.27 4
c. 27 6
d. 64 6

79.

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 43

Version 1.0 Revision Date: 30/08/08

What would be the output of the following program.


main()
{
const int x=get();
printf("%d",x);
}
get()
{
return(20);
}
a. 20
b. garbage value
c. error
d. 0

80.
What would be the output of the following program.
#include<stdio.h>
main()
{
char str[5]="fast";
static char *ptr_to_array = str;
printf("%s",ptr_to_array);

}
a. Compilation will only give a warning but will proceed to
execute & will display "fast"
b. display "fast" on screen
c. will give a compilation error.
d. none of the above
81.
What will be the output of the following program?

int main()

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 44

Version 1.0 Revision Date: 30/08/08

printf();

return(0);

(a)Run-Time Error

(b)Compile-Time Error

(c)No Output

(d)None of these
82.
What will be the output of the following program?

int main()

printf(NULL);

return(0);

a. Run-Time Error (NULL is not defined)

b. Compile-Time Error

c. No Output

d. None of these

83.
What will be the output of the following program?

int main()

printf("%d", printf("Hi!") + printf("Bye"));

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 45

Version 1.0 Revision Date: 30/08/08

return(0);

a. ByeHi!6

b. Hi!Bye6

c. Compile-Time Error

d. None of these

84.

What will be the output of the following program?

int main()

printf("Hi Friends"+3);

return(0);

a.Hi Friends

b.Friends

c.Hi Friends3

d. None of these

85.

What will be the output of the following program?

int main()

int main=7;

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 46

Version 1.0 Revision Date: 30/08/08

printf("%d", main);

return main;

printf("Bye");

return(0);

(a)Compile-Time Error

(b)Run-Time Error

(c)7Bye

(d)7

86.

What will be the output of the following program?

int main()

int val = 5;

printf("%*d", val);

return(0);

(a)bbbbb5 (where b means a space)

(b)5

(c)Compile-Time Error

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 47

Version 1.0 Revision Date: 30/08/08

(d)None of these

87.

What will be the output of the following program?

int main()

char str[]="C For Swimmers";

printf("%d",sizeof str);

return(0);

(a)14

(b)Compile-Time Error

(c)15

(d)None of these

88.

What will be the output of the following program? [NOTE: THE USER
INPUT IS: 123456 44 544]

int main()

int a, b, c;

scanf("%1d %2d %3d", &a, &b, &c);

printf("Sum = %d", a+b+c);

return(0);

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 48

Version 1.0 Revision Date: 30/08/08

(a)Sum=480

(b)Sum=594

(c)Sum=589

(d)None of these

89.

What will be the output of the following program :

int main()

printf("Hi!");

if (0 || -1)

printf("Bye");

return(0);

(a)No Output

(b)Hi!

(c)Bye

(d)Hi!Bye

90.

What will be the output of the following program :

int main()

for (;printf(""););

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 49

Version 1.0 Revision Date: 30/08/08

return(0);

(a)Compile-Time error

(b)Executes ONLY once

(c)Executes INFINITELY

(d)None of these

91.What will be the output of the following program :

void print(int a[],...)

while (*a != -1)

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

int main()

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

print(a,5,6,7,8,9,-1);

return(0);

(a)Compile-Time Error

(b)Run-Time Error

(c)12345

(d)56789

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 50

Version 1.0 Revision Date: 30/08/08

92.

What will be the output of the following program :

int main()

int val=1234;

int* ptr=&val;

printf("%d %d",++val,*ptr);

return(0);

(a)1234 1234

(b)1235 1235

(c)1234 1235

(d)1235 1234

93.

What will be the output of the following program :

int main()

int (*a)[5];

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

return(0);

(a)Compile-Time Error

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 51

Version 1.0 Revision Date: 30/08/08

(b)20 4

(c)5 2

(d)None of these

94.

What will be the output of the following program :

union A {

char ch;

int i;

float f;

}tempA;

int main()

tempA.ch='A';

tempA.i=777;

tempA.f=12345.12345;

printf("%d",tempA.i);

return(0);

(a)Compile-Time Error

(b)12345

(c)Erroneous output

(d)777

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 52

Version 1.0 Revision Date: 30/08/08

95.

What will be the output of the following program :

int main()

int i=5;

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

return(0);

(a)Compile-Time Error

(b)10 9 8 7 6

(c)9 8 7 6 6

(d)10 8 7 6 6

96.

What is the Output of the Program ?

main()

int a = 1;

#define p a

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

a) 1, 0

b) 2, 0

c) 1 2

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 53

Version 1.0 Revision Date: 30/08/08

d) none of the above

97.

What is the Output of the Program ?

int g = 10 ;

main()

int a = 10 ;

printf("%d",a) ;

int g ;

a. 10

b. 11

c. error
d. none
98.

Point out the error, if any, in the for loop


main()
{

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 54

Version 1.0 Revision Date: 30/08/08

int l=1;
for(;;)
{
printf("%d",l++);
if(l>10)
break;
}
}

(a) The condition in the for loop is a must


(b) The two semicolons should be dropped
(c) The for loop should be replaced by awhile loop

(d) No error

99.
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);
}
}

a) 0,5,9,13,17
b) 5,9,13,17
c) 12,17,2
d) Syntax error

100.
Find the output for the following C program

2008 Softwares House Softwares House Document Security Classification:


Confidential
C LANGUAGE Page 55

Version 1.0 Revision Date: 30/08/08

#include<stdio.h>
main()
{
char s1[]="Ramco";
char s2[]="Systems";
s1=s2;
printf("%s",s1);
}

a. Ramco
b. Ramco systems

c. Error

d. None of these

2008 Softwares House Softwares House Document Security Classification:


Confidential

You might also like