You are on page 1of 10

1.

)
void main()
{
Int const *p=5;
Printf(%d,++(*p));
}
A)
B)
C)
D)

6
5
Next Location
Error

2.)Void main()
{
Float me=1.1;
Double you=1.1;
If(me==you)
Printf(I Love U);
Else
Printf(I Hate U);
}
A)
B)
C)
D)

I Love U
I Hate U
Error since we cant compare two floating point numbers
I Love U I Hate U

3.)void main()
{
int i=3,*j,**k,**m;
j=&i;
k=&j;
m=*(&k);
printf("%d %d %d %d",*j,**k,*(*k),**m);
getch();
}

A)
B)
C)
D)

4333
2333
3334
3333

4.)
Void main()
{
Int z,x=5,y=-10,a=4,b=2;
Z=x++ - --y *b/a;
Cout<<z;
}
A)5
B)12
C)11

D)10

5.)Void main()
{
For(int i=1; i<=10; i++);
Cout<<i;
}
A)
B)
C)
D)

Compiler Error
Logical Error
Linking Error
No Error

6.) Void main()


{
Int x=5;
Printf(%d %d %d,x,x<<2,x>>2);
}
A)
B)
C)
D)

15 20 1
1 20 5
5 20 1
None of these

7). Which one of the following statements allocates enough space to hold an array of 10
integers that are initialized to 0
A) int *ptr=(int*)malloc(10,sizeof(int));
B) int *ptr=(int*)calloc(10,sizeof(int));
C) int *ptr=(int*)malloc(10*sizeof(int));
D) int *ptr=(int*)calloc(10*sizeof(int));

8). Which one of the following cant be used as an identifier?


A) _123ab
B) ab_123
C)1ab_
D)a123

Part 2:
1.)
void main()
{
int a=5;
int b=10;

{
int b=2;
a++;
b++;
}
printf("%d %d",b,a);
getch();
}
ANS:
a.)10 6
b.)10 5
c.)3 6
d.)3 garbage
e.)3 5
2.)void main(){
char *str;
scanf("%[^\n]",str);
printf("%s",str);
}
(a)It will accept a word as a string from user.
(b)It will accept a line as a string from user.
(c)It will accept a paragraph as a string from user.
(d)Compiler error
(e)None of above

3.)
void main(){
float f=3.4e39;
printf("%f",f);
}
(a)3.4e39
(b)3.40000
(c)+INF
(d)Compiler error
(e)Run time error

4.)
enum color{RED,GREEN=32767,BLUE,YELLOW
};
enum color x;
x=YELLOW;
printf("%d %d ",RED,YELLOW);
(a)32766 garbage
(b)-32766 32769
(c)0 32768
(d)Compiler error
(e) 0 -32767

5.) void main(){

char *url="c:\tc\bin\rw.c";
printf("%s",url);

getch();
}
ANS:
(a)c:\tc\bin\rw.c
(b)c:/tc/bin/rw.c
(c)c: c inw.c
(d)c:cinw.c
(e)w.c
in

6.) void main(){

clrscr();
goto abc;
printf("main");
getch();
}
void dispaly(){
abc:
printf("display");
}
(a)main
(b)display
(c)maindisplay
(d)displaymain
(e)Compiler error
7.)
void main(){
int i=11;
int const * p=&i;
p++;
printf("%d",*p);
}
(a)11
(b) 12
(c)Garbage value
(d)Compiler error
(e)None of above
8.)void main(){
int i=11;
int const * p=&i;
(*p)++;
printf("%d",*p);
}
(a)11
(b) 12
(c)Garbage value
(d)Compiler error
(e)None of above

Part 3(k):
1. 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]);
}
2.

main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
}
3. 3. main()
{
printf("%x",-1<<4);
}
4. main()
{
char string[]="Hello World";
display(string);
}
void display(char *string)
{
printf("%s",string);
}
5. #define int char
main()
{
int i=65;
printf("sizeof(i)=%d",sizeof(i));
}
6. main()
{
char *p="hai friends",*p1;
p1=p;

while(*p!='\0') ++*p++;
printf("%s %s",p,p1);
}

7.)

8.)

9.)

main()
{
int i;
printf("%d",scanf("%d",&i)); // value 10 is given as input here
}
#define f(g,g2) g##g2
main()
{
int var12=100;
printf("%d",f(var,12));
}
main()
{
int i=0;
for(;i++;printf("%d",i)) ;
printf("%d",i);
}

10.)

main()
{
int a=10;
void f();
a=f();
printf(\n%d,a);
}
void f()
{
printf(\n Hi);
}

11.)

main()
{
int i, n;
char *x = girl;
n = strlen(x);
*x = x[n];
for(i=0; i<n; ++i)
{
printf(%s\n,x);
x++;

12.)

13).

}
}
#define sqr(x) (x*x)
main()
{
int a,b=3;
a=sqr(b+2);
printf(%d,a);
}

main()
{
int k=1;
printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE");
}

You might also like