| Other C Code Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| const int perplexed = 2;
#define perplexed 3
main()
{
#ifdef perplexed
#undef perplexed
#define perplexed 4
#endif
printf("%d",perplexed);
}
a. 0
b. 2
c. 4
d. none of the above | HCL | 1 |
| Extend the sutherland-hodgman clipping algorithm to clip
three-dimensional planes against a regular paralleiepiped | IBM | 1 |
| main()
{
int i=0;
for(;i++;printf("%d",i)) ;
printf("%d",i);
} | | 1 |
| main()
{
char *p = "hello world";
p[0] = 'H';
printf("%s", p);
}
a. Runtime error.
b. “Hello world”
c. Compile error
d. “hello world” | HCL | 1 |
| int i,j;
for(i=0;i<=10;i++)
{
j+=5;
assert(i<5);
} | | 1 |
| Sorting entire link list using selection sort and insertion
sort and calculating their time complexity | NetApp | 1 |
| #include<stdio.h>
main()
{
register i=5;
char j[]= "hello";
printf("%s %d",j,i);
} | | 1 |
| Write a routine to draw a circle (x ** 2 + y ** 2 = r ** 2)
without making use of any floating point computations at all. | Microsoft | 2 |
| What is "far" and "near" pointers in "c"...? | | 3 |
| 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 |
| 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 |
| Is the following statement a declaration/definition. Find
what does it mean?
int (*x)[10]; | | 1 |
| main()
{
extern int i;
i=20;
printf("%d",sizeof(i));
} | | 1 |
| Give a one-line C expression to test whether a number is a
power of 2. | Microsoft | 8 |
| #ifdef something
int some=0;
#endif
main()
{
int thing = 0;
printf("%d %d\n", some ,thing);
} | | 1 |
| main()
{
char *cptr,c;
void *vptr,v;
c=10; v=0;
cptr=&c; vptr=&v;
printf("%c%v",c,v);
} | | 1 |
| How to read a directory in a C program?
| | 4 |
| main()
{
char *p = “ayqm”;
printf(“%c”,++*(p++));
} | TCS | 2 |
| # include<stdio.h>
aaa() {
printf("hi");
}
bbb(){
printf("hello");
}
ccc(){
printf("bye");
}
main()
{
int (*ptr[3])();
ptr[0]=aaa;
ptr[1]=bbb;
ptr[2]=ccc;
ptr[2]();
} | | 1 |
| main()
{
char a[4]="HELLO";
printf("%s",a);
} | | 1 |
| |
| For more C Code Interview Questions Click Here |