| Other C Code Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| void main()
{
if(~0 == (unsigned int)-1)
printf(“You can answer this if you know how values are
represented in memory”);
} | | 1 |
| main()
{
char string[]="Hello World";
display(string);
}
void display(char *string)
{
printf("%s",string);
} | | 1 |
| Write a program that find and print how many odd numbers in
a binary tree | | 1 |
| String copy logic in one line. | NetApp | 9 |
| void main()
{
static int i;
while(i<=10)
(i>2)?i++:i--;
printf(“%d”, i);
} | | 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 |
| main()
{
int i=-1;
-i;
printf("i = %d, -i = %d \n",i,-i);
} | | 1 |
| Finding a number which was log of base 2 | NetApp | 1 |
| Give a one-line C expression to test whether a number is a
power of 2. | Microsoft | 8 |
| #define max 5
#define int arr1[max]
main()
{
typedef char arr2[max];
arr1 list={0,1,2,3,4};
arr2 name="name";
printf("%d %s",list[0],name);
} | | 1 |
| main()
{
int i = 258;
int *iPtr = &i;
printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) );
} | | 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()
{
void *v;
int integer=2;
int *i=&integer;
v=i;
printf("%d",(int*)*v);
} | | 1 |
| What are the following notations of defining functions known as?
i. int abc(int a,float b)
{
/* some code */
}
ii. int abc(a,b)
int a; float b;
{
/* some code*/
} | | 1 |
| int i,j;
for(i=0;i<=10;i++)
{
j+=5;
assert(i<5);
} | | 1 |
| print numbers till we want without using loops or condition
statements like specifically(for,do while, while swiches,
if etc)!
| | 7 |
| main()
{
int i=400,j=300;
printf("%d..%d");
} | | 1 |
| main()
{
char c;
int i = 456;
clrscr();
c = i;
printf("%d", c);
}
a. 456
b. -456
c. random number
d. none of the above | HCL | 1 |
| main()
{
float f=5,g=10;
enum{i=10,j=20,k=50};
printf("%d\n",++k);
printf("%f\n",f<<2);
printf("%lf\n",f%g);
printf("%lf\n",fmod(f,g));
} | | 1 |
| Is the following code legal?
struct a
{
int x;
struct a b;
} | | 1 |
| |
| For more C Code Interview Questions Click Here |