| Other C Code Interview Questions |
| | | Question | Asked @ | Answers | | | | int i,j;
for(i=0;i<=10;i++)
{
j+=5;
assert(i<5);
} | | 1 | | struct aaa{
struct aaa *prev;
int i;
struct aaa *next;
};
main()
{
struct aaa abc,def,ghi,jkl;
int x=100;
abc.i=0;abc.prev=&jkl;
abc.next=&def;
def.i=1;def.prev=&abc;def.next=&ghi;
ghi.i=2;ghi.prev=&def;
ghi.next=&jkl;
jkl.i=3;jkl.prev=&ghi;jkl.next=&abc;
x=abc.next->next->prev->next->i;
printf("%d",x);
} | | 1 | | Is the following code legal?
void main()
{
typedef struct a aType;
aType someVariable;
struct a
{
int x;
aType *b;
};
} | | 1 | | main()
{
int x=5;
clrscr();
for(;x==0;x--) {
printf("x=%d\n", x--);
}
}
a. 4, 3, 2, 1, 0
b. 1, 2, 3, 4, 5
c. 0, 1, 2, 3, 4
d. none of the above | HCL | 1 | | void main()
{
while(1){
if(printf("%d",printf("%d")))
break;
else
continue;
}
} | | 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 | | void main()
{
static int i=5;
if(--i){
main();
printf("%d ",i);
}
} | | 1 | | main()
{
register int a=2;
printf("Address of a = %d",&a);
printf("Value of a = %d",a);
} | | 1 | | 1)
int i=5;
j=i++ + i++ + i++;
printf("%d",j);This code gives the answer 15.But if we
replace the value of the j then anser is different?why?
2)int i=5;
printf("%d",i++ + i++ + i++);
this givs 18. | Infosys | 6 | | #if something == 0
int some=0;
#endif
main()
{
int thing = 0;
printf("%d %d\n", some ,thing);
} | | 1 | | Which version do you prefer of the following two,
1) printf(%s,str); // or the more curt one
2) printf(str); | | 1 | | main()
{
41printf("%p",main);
}8 | | 1 | | Write a routine that prints out a 2-D array in spiral order | Microsoft | 2 | | plz send me all data structure related programs | | 1 | | main()
{
int i, j, *p;
i = 25;
j = 100;
p = &i; // Address of i is assigned to pointer p
printf("%f", i/(*p) ); // i is divided by pointer p
}
a. Runtime error.
b. 1.00000
c. Compile error
d. 0.00000 | HCL | 1 | | struct Foo
{
char *pName;
char *pAddress;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
clrscr();
obj->pName = malloc(100);
obj->pAddress = malloc(100);
strcpy(obj->pName,"Your Name");
strcpy(obj->pAddress, "Your Address");
free(obj);
printf("%s", obj->pName);
printf("%s", obj->pAddress);
}
a. Your Name, Your Address
b. Your Address, Your Address
c. Your Name Your Name
d. None of the above | HCL | 1 | | #define SQR(x) x * x
main()
{
printf("%d", 225/SQR(15));
}
a. 1
b. 225
c. 15
d. none of the above | HCL | 1 | | How will you print % character?
a. printf(\%)
b. printf(\\%)
c. printf(%%)
d. printf(\%%) | HCL | 1 | | int DIM(int array[])
{
return sizeof(array)/sizeof(int );
}
main()
{
int arr[10];
printf(The dimension of the array is %d, DIM(arr));
} | | 1 | | main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%d\n", bit >> (i - (i -1)));
}
}
a. 512, 256, 0, 0, 0
b. 256, 256, 0, 0, 0
c. 512, 512, 512, 512, 512
d. 256, 256, 256, 256, 256 | HCL | 1 | | | | For more C Code Interview Questions Click Here |
|