Saturday, July 23, 2011

C Aptitude - P3

1.      main()
{
            char string[]="Hello World";
            display(string);
}
void display(char *string)
{
            printf("%s",string);
}

2.      main()
{
            int c=- -2;
            printf("c=%d",c);
}

3.      #define int char
main()
{
            int i=65;
            printf("sizeof(i)=%d",sizeof(i));
}

4.      main()
{
int i=10;
i=!i>14;
Printf ("i=%d",i);
}

5.      #include"stdio.h"
main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32);
}

6.      #include"stdio.h"
main()
{
int a[2][2][2] = { {10,2,3,4}, {5,6,7,8}  };
int *p,*q;
p=&a[2][2][2];
*q=***a;
printf("%d----%d",*p,*q);
}

7.      #include"stdio.h"
main()
{
struct xx
{
      int x=3;
      char name[]="hello";
 };
struct xx *s;
printf("%d",s->x);
printf("%s",s->name);
}

8.      #include"stdio.h"
main()
{
struct xx
{
int x;
struct yy
{
char s;
            struct xx *p;
};
struct yy *q;
};
}
9.      main()
{
printf("\nab");
printf("\bsi");
printf("\rha");
}

10.      main()
{
int i=5;
printf("%d%d%d%d%d%d",i++,i--,++i,--i,i);
}

Find the Answers.

1 comment: