Sunday, June 8, 2008

Paper 1

Q2. What does int *x[](); means ?


Q3. struct list{
int x;
struct list *next;
}*head;

the struct head.x =100

Is the above assignment to pointer is correct or wrong ?

Ans. Wrong

Q4.What is the output of the following ?

int i;
i=1;
i=i+2*i++;
printf(%d,i);

Ans. 4

Q5. FILE *fp1,*fp2;
fp1=fopen("one","w")
fp2=fopen("one","w")
fputc('A',fp1)
fputc('B',fp2)
fclose(fp1)
fclose(fp2)
}

Find the Error, If Any?

Ans. no error. But It will over writes on same file.

What are the output(s) for the following ?

Q6. #include
char *f()
{
char *s=malloc(8);
strcpy(s,"goodbye");
}

main()
{
char *f();
printf("%c",*f()='A');
}


Q7. #define MAN(x,y) (x)>(y)?(x):(y)
{
int i=10;
j=5;
k=0;
k=MAX(i++,++j);
printf(%d %d %d %d,i,j,k);
}

Ans. 10 5 0


Q8. a=10;
b=5; c=3;
d=3;
if(a < b)&&(c=d++)
printf(%d %d %d %d a,b,c,d);
else
printf("%d %d %d %d a,b,c,d);


Q9. #include
show(int t,va_list ptr1)
{
int a,x,i;
a=va_arg(ptr1,int);
printf("\n %d",a);
}
display(char)
{
int x;
listptr;
va_star(otr,s);
n=va_arg(ptr,int);
show(x,ptr);
}

main()
{
display("hello",4,12,13,14,44);
}


Q10. main()
{
printf("hello");
fork();
}


Q11. main()
{
int i = 10;
printf(" %d %d %d \n", ++i, i++, ++i);
}


Q12. #include
main()
{
int *p,*c,i;
i = 5;
p = (int*) (malloc(sizeof(i)));
printf("\n%d",*p);
*p = 10;
printf("\n%d %d",i,*p);
c = (int*) calloc(2);
printf("\n%d\n",*c);
}

No comments: