Sie sind auf Seite 1von 8

C Programming Test ( ECE & EE )

Mock Campus

( 2009 Batch )

MOCK Campus 2008 (C Programming)


Electronics & Electrical Engg.
No of Question : 30

1)

Time limit : 30 minutes

Find the output for the


following C program

(a) 10
(c) 7

(b) 8
(d) Compilation error

main()
{char *p1="Name";

3) Find the output for the following C


program

char *p2;
main()
p2=(char *)malloc(20);
{char a[10]="hello";
while(*p2++=*p1++);
strcpy(a,'\0');
printf("%s\n",p2);
printf("%s",a);
}
}
(a) Name
(c) program error

(b) Empty string


(d) emaN

2) Find the output for the following C


program

(a) string is null


(b) string is not
null (c) program error
(d) hello

4) Find the output for the following C


program

#define SUM(a,b) a+b


void main()
main()
{ unsigned i=1;
{a=2;
signed j=-1;
b=3;
if(i<j)
x=SUM(a,b)*2;
printf("less");
printf("x=%d\n",x);
else
}
if(i>j)

Training and Placement Office , MNNIT Allahabad


of 8

Page 1

C Programming Test ( ECE & EE )

Mock Campus

( 2009 Batch )

printf("greater");

else

(a) dharmadharmahewlett-packard
(b) harmaharmaewlett-packard
(c) hewlett-packardsiemensbm
(d) Compilation error

if(i==j)
printf("equal"); }
(a) greater
(c) less
error

(b) equal
(d) Compilation

7) Find the output for the following C


program
void main()
{ int i;
for(i=1;i<4,i++)

5) Find the output for the following C


program

switch(i)
#define one 0
case 1: printf("%d",i);break;
#ifdef one
{ case 2:printf("%d",i);break;
printf("one is defined ");
case 3:printf("%d",i);break;
#ifndef one
}
printf("one is not defined ");
switch(i) case 4:printf("%d",i);
(a) one is defined
(b) one is not
defined
(c) empty string
(d)
Compilation error

}
(a) Compilation error
error (c) 1234
output

(b) Run-time
(d) no

6) Find the output for the following C


program
void main()
{
char *s[ ]={ "dharma","hewlettpackard","siemens","ibm"};

8) Find the output for the following C


program
main()

char **p;

{char *ptr = "Ramco Systems";

p=s;

(*ptr)++;

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

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

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

printf("%s",++*p);
Training and Placement Office , MNNIT Allahabad
of 8

Page 2

C Programming Test ( ECE & EE )

Mock Campus

( 2009 Batch )

(a) Samco Systems (b) Ramco


Systems (c) Systems
(d)
Compilation error

9) Find the output for the following C


program

}
(a) Hello!
(c) To All

(b) Welcome
(d) Welcome To All

11) Find the output for the following C


Program

#include<stdio.h>
int bags[5]={20,5,20,3,20};
main()
void main(void)
{char s1[]="Ramco";
{int pos=5,*next();
char s2[]="Systems";
*next()=pos;
s1=s2;
printf("%d %d %d",pos,*next(),bags[0]);
printf("%s",s1);
}
}
int *next()
(a) Samco Systems
(b) Ramco
Systems
(c) Compilation error (d)
Run-time error

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

10) Find the output for the following C


program

if (bags[i]==20)

void main(void)

return(bags+i);

{unsigned int c=9;

printf("Error!");

unsigned x=0x3;

exit(0);

switch(c&x)

(a) 5 20 5
(c) 20 3 20

(b) 20 5 20
(d) 5 20 3

case 3: printf("Hello!\t");
case 2: printf("Welcome\t");

12) Find the output for the following C


program

case 1: printf("To All\t");

void main(void)

default:printf("\n");

{int y,z;

int x=y=z=10;

Training and Placement Office , MNNIT Allahabad


of 8

Page 3

C Programming Test ( ECE & EE )

Mock Campus

( 2009 Batch )

int f=x;
float ans=0.0;

15) In the following code what will be


the result of the function, value of x ,
value of y

f *=x*y;

main()

ans=x/3.0+y/3;

{unsigned int x=-1;

printf("%d %.2f",f,ans);

int y;

y = ~0;

(a) 10000 6
(c) 1000 6.33

(b) 1000 6.333


(d) 10000 6.33

if(x == y)
printf("same");
else

13) Find the output for the following C


program

printf("not same");

void main()

{char *s="\12345s\n";

a) same, MAXINT, -1
b) not same, MAXINT, -MAXINT
c) same , MAXUNIT, -1
d) same, MAXUNIT, MAXUNIT

printf("%d",sizeof(s));
}
(a) 5
error

(c) 7

(b) Compilation
(d) 6

16) Find the output for the following C


program
main()

14) Find the output for the following C


program

{char c=-64;

void main()

int i=-32;

{float j;

unsigned int u =-16;

j=1000*1000;

if(c>i)

printf("%f",j);

{printf("pass1,");

if(c<u)

(a). 10000
(b).
Overflow (c). Compilation Error
(d). None

printf("pass2");

Training and Placement Office , MNNIT Allahabad


of 8

else

Page 4

C Programming Test ( ECE & EE )

Mock Campus

( 2009 Batch )

printf("Fail2");

free(a);

else

(a) Swap contents of p & a and print:


(New string, string)
(b) Generate compilation error in line
number 8
(c) Generate compilation error in line
number 5
(d) Generate compilation error in line
number 7

printf("Fail1);
if(i<u)
printf("pass2");
else

18) Find the error for the following C


program

printf("Fail2")

FILE *fp1,*fp2;

}
a) Pass1,Pass2
c) Fail1,Pass2

b) Pass1,Fail2
d) Fail1,Fail2

fp1=fopen("one","w")
fp2=fopen("one","w")
fputc('A',fp1)

17) Find the output for the following C


program

fputc('B',fp2)

void main()

fclose(fp1)

{int i;

fclose(fp2)

char a[]="String";

char *p="New Sring";


char *Temp;

(a) Run time error


(b) Compilation
error
(c) L-Valve required (d) no
error

Temp=a;
a=malloc(strlen(p) + 1);

19). A binary tree with 20 nodes has


______ null branches?

strcpy(a,p); //Line number:9//


p = malloc(strlen(Temp) + 1);
strcpy(p,Temp);

20).
______ Minimum number of
queues needed to implement the priority
queue?

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

Training and Placement Office , MNNIT Allahabad


of 8

21) In the following C program


Page 5

C Programming Test ( ECE & EE )

Mock Campus

( 2009 Batch )

void x(char* a)

f(p);

{ (a[0])?x(a+1):1;

printf("%s",p);

printf("%c",*(a+0));

return 1;

(a) BYE
(c) BYEhello

(b) hello
(d) helloBYE

..;
}
Input string 'a' is assigned as AaBbCc ,
what is the output?

25). what does the following program


do ?
f(int n)

(a) AaBbCc
(c) BbaCAc

(b) cCbBaA
(d) bBCacA

22) In worst case ,which sort is best out


of following sorts?

{ int c;
while(n)
{ n&=n-1;

(a).heap
(c).quick

(b).selection
(d). insertion

c++;
}

23). p points to an integer. We don't want


p to change value. In C, what
declarations will we use?

print c;

a). const int *p


(c). int const *p
const p

___________________

(b) . int *p
(d). int*

26) Find the output for the following C


program
24) Find the output for the following C
program

void main()

Void f(char *p)

{int d=5;

{ p = (char*)malloc(6);

printf("%f",d);

strcpy(p,"hello");

(a) 5.0
error (c) 5
Undefined

void main( )

(b) Compilation
(d)

{ char *p = "BYE";
Training and Placement Office , MNNIT Allahabad
of 8

Page 6

C Programming Test ( ECE & EE )

Mock Campus

( 2009 Batch )

27). What is this called


(char *) (*(*(*A[X]) ( ) )) ( )

break;}
printf("%d,",i);

_______________
}
28) In the following C program
}
int f()
a) 0,5,9,13,17
c) 12,17,22

void main()

b) 5,9,13,17
d) 16,21

{f(1);
f(1,2);

30) In the following C program :

f(1,2,3);

void swap(int*,int*);

main()

f(int i,int j,int k)

int arr[8]={36,8,97,0,161,164,3,9}

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

for (int i=0; i<7; i++)

The no of syntax errors are


a) 1

b) 2

c) 3

for (int j=i+1; j<8;j++)


d) none

if(arr[i]<arr[j])
swap(&arr[i],&arr[j]);
}

29). Output of the following program is


}
main()
void swap(int*x,int*y)
{int i=0;
{ int temp; static int cnt=0;
for(i=0;i<20;i++)
temp= *x;
{switch(i)
*x=*y;
case 0:i+=5;
*y=temp;
case 1:i+=2;
cnt++;
case 5:i+=5;
}
default i+=4;
Training and Placement Office , MNNIT Allahabad
of 8

Page 7

C Programming Test ( ECE & EE )

Mock Campus

( 2009 Batch )

What is cnt equal to


a) 7
c) 1

b) 15
d) none of these

Training and Placement Office , MNNIT Allahabad


of 8

Page 8

Das könnte Ihnen auch gefallen