Friday, July 25, 2008

questions on C code

1.
#include
#define MAX(a,b) a>b?a:b
main()
{
int x;
x=MAX(3+2,2+7);
printf("%d",x);
}
ans: 9.
2. & 3 this ? asked twice in paper.
#include
main()
{
FILE *fp;
fp= fopen("trial","r");
}
what fp indicate ?
4.
#include
main()
{
unsigned int m=32;
printf("%x",~m);
}
ans: ffdf.
5. i don't know perfect.... output of this.
#include
main()
{
FILE *fp1,fp2;
fp1=fopen("one","w");
fp1=fopen("one","w");
fputc('A',fp1);
fputc('B',fp2);
}

6. output
#include
main()
{
char ch='A';
printf("%d %d",sizeof(ch),sizeof('A'));
}
ans: 1 1.

7. output
#include
struct a
{
member : 5;
cost : 6;
};
main()
{
printf("%d",sizeof(a));
}
ans: 2.

8.what is not associate with switch statement?

9.
#include
#include
struct a
{
char *x;
int y;
};
main()
{
struct a e1={"Raju",36};
struct a e2=e1;
e2.x="Ramesh";
strupr(e2.x);
printf("%s",e1.x);
}
ans: Raju.
10. i don't perfect. its like...
#include
main()
{
int n=20;
printf("%d",n,n);
}
ans: 20.
*****************************************************

0 comments: