| Other C Code Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| Is the following code legal?
struct a
{
int x;
struct a *b;
} | | 1 |
| #include<stdio.h>
main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
} | | 1 |
| main()
{
char a[4]="HELL";
printf("%s",a);
} | Wipro | 1 |
| main()
{
int i=4,j=7;
j = j || i++ && printf("YOU CAN");
printf("%d %d", i, j);
} | | 1 |
| #include<stdio.h>
main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s=malloc(sizeof(struct xx));
printf("%d",s->x);
printf("%s",s->name);
} | | 1 |
| #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);
} | | 1 |
| Is this code legal?
int *ptr;
ptr = (int *) 0x400; | | 1 |
| main()
{
char * strA;
char * strB = I am OK;
memcpy( strA, strB, 6);
}
a. Runtime error.
b. I am OK
c. Compile error
d. I am O | HCL | 2 |
| main()
{
int i=0;
for(;i++;printf("%d",i)) ;
printf("%d",i);
} | | 1 |
| #include<stdio.h>
main()
{
const int i=4;
float j;
j = ++i;
printf("%d %f", i,++j);
} | | 1 |
| main()
{
char string[]="Hello World";
display(string);
}
void display(char *string)
{
printf("%s",string);
} | | 1 |
| void ( * abc( int, void ( *def) () ) ) (); | | 1 |
| main()
{
int y;
scanf("%d",&y); // input given is 2000
if( (y%4==0 && y%100 != 0) || y%100 == 0 )
printf("%d is a leap year");
else
printf("%d is not a leap year");
} | | 1 |
| main()
{
void swap();
int x=10,y=8;
swap(&x,&y);
printf("x=%d y=%d",x,y);
}
void swap(int *a, int *b)
{
*a ^= *b, *b ^= *a, *a ^= *b;
} | | 1 |
| #define f(g,g2) g##g2
main()
{
int var12=100;
printf("%d",f(var,12));
} | | 1 |
| How to return multiple values from a function?
| | 4 |
| main()
{
if (!(1&&0))
{
printf("OK I am done.");
}
else
{
printf("OK I am gone.");
}
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above | HCL | 1 |
| main()
{
int i=5;
printf("%d%d%d%d%d%d",i++,i--,++i,--i,i);
} | | 1 |
| Given n nodes. Find the number of different structural
binary trees that can be formed using the nodes. | Aricent | 7 |
| main()
{
int i;
printf("%d",scanf("%d",&i)); // value 10 is given as
input here
} | | 1 |
| |
| For more C Code Interview Questions Click Here |