| Other C Code Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| Is the following statement a declaration/definition. Find
what does it mean?
int (*x)[10]; | | 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 |
| void main()
{
int i=i++,j=j++,k=k++;
printf(“%d%d%d”,i,j,k);
} | | 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 |
| main()
{
char *p;
p="%d\n";
p++;
p++;
printf(p-2,300);
} | | 1 |
| Find the largest number in a binary tree | Infosys | 4 |
| Give a very good method to count the number of ones in a 32
bit number.
(caution: looping through testing each bit is not a solution) | Microsoft | 5 |
| main()
{
char not;
not=!2;
printf("%d",not);
} | | 1 |
| How to access command-line arguments? | | 4 |
| main()
{
char *p = “ayqm”;
printf(“%c”,++*(p++));
} | TCS | 2 |
| Is the following code legal?
void main()
{
typedef struct a aType;
aType someVariable;
struct a
{
int x;
aType *b;
};
} | | 1 |
| Finding a number which was log of base 2 | NetApp | 1 |
| main()
{
signed int bit=512, mBit;
{
mBit = ~bit;
bit = bit & ~bit ;
printf("%d %d", bit, mBit);
}
}
a. 0, 0
b. 0, 513
c. 512, 0
d. 0, -513 | HCL | 1 |
| main()
{
printf("%x",-1<<4);
} | | 1 |
| plz send me all data structure related programs | | 2 |
| enum colors {BLACK,BLUE,GREEN}
main()
{
printf("%d..%d..%d",BLACK,BLUE,GREEN);
return(1);
} | | 1 |
| #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);
} | | 1 |
| print numbers till we want without using loops or condition
statements like specifically(for,do while, while swiches,
if etc)!
| | 7 |
| void main()
{
char far *farther,*farthest;
printf("%d..%d",sizeof(farther),sizeof(farthest));
} | | 1 |
| main()
{
int i=-1;
+i;
printf("i = %d, +i = %d \n",i,+i);
} | | 1 |
| |
| For more C Code Interview Questions Click Here |