Q1. typedef struct
{char *;
nodeptr next;
} *nodeptr;
What does nodeptr stand for?
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(Cool;
strcpy(s,"goodbye");
}
main()
{
char *f();
printf("%c",*f()='A');
}
Q7. #define MAN(x,y) (x)>(y)?(x)Sady)
{
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
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);
}
Q13. #define MAX(x,y) (x) >(y)?(x)Sady)
main()
{
int i=10,j=5,k=0;
k= MAX(i++,++j);
printf("%d..%d..%d",i,j,k);
}
Q14. #include
main()
{
enum _tag{ left=10, right, front=100, back};
printf("left is %d, right is %d, front is %d, back is %d",left,right,front,back);
}
Q15. main()
{
int a=10,b=20;
a>=5?b=100:b=200;
printf("%d\n",b);
}
Q16. #define PRINT(int) printf("int = %d ",int)
main()
{
int x,y,z;
x=03;y=02;z=01;
PRINT(x^x);
z<<=3; PRINT(x); y»=3; PRINT(y); } Q17. #include
main()
{
char s[] = "Bouquets and Brickbats";
printf("\n%c, ",*(&s[2]));
printf("%s, ",s+5);
printf("\n%s",s);
printf("\n%c",*(s+2));
}
Q18. main()
{
struct s1
{
char *str;
struct s1 *ptr;
};
static struct s1 arr[] = {
{"Hyderabad",arr+1},
{"Bangalore",arr+2},
{"Delhi",arr}
};
struct s1 *p[3];
int i;
for(i=0;i<=2;i++) p = arr.ptr; printf("%s\n",(*p)->str);
printf("%s\n",(++*p)->str);
printf("%s\n",((*p)++)->str);
}
Q19. main()
{
char *p = "hello world!";
p[0] = 'H';
printf("%s",p);
}