| Other C Code Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| How to return multiple values from a function?
| | 4 |
| main()
{
int i=-1;
+i;
printf("i = %d, +i = %d \n",i,+i);
} | | 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 |
| 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=5;
printf("%d",++i++);
} | | 1 |
| # 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 |
| void main()
{
char ch;
for(ch=0;ch<=127;ch++)
printf(%c %d \n, ch, ch);
} | | 1 |
| main()
{
unsigned int i=10;
while(i-->=0)
printf("%u ",i);
} | | 1 |
| struct Foo
{
char *pName;
};
main()
{
struct Foo *obj = malloc(sizeof(struct Foo));
clrscr();
strcpy(obj->pName,"Your Name");
printf("%s", obj->pName);
}
a. Your Name
b. compile error
c. Name
d. Runtime error | HCL | 1 |
| Find your day from your DOB? | Microsoft | 12 |
| Given n nodes. Find the number of different structural
binary trees that can be formed using the nodes. | Aricent | 7 |
| char *someFun1()
{
char temp[ ] = string";
return temp;
}
char *someFun2()
{
char temp[ ] = {s, t,r,i,n,g};
return temp;
}
int main()
{
puts(someFun1());
puts(someFun2());
} | | 1 |
| union u
{
union u
{
int i;
int j;
}a[10];
int b[10];
}u;
main()
{
printf("\n%d", sizeof(u));
printf(" %d", sizeof(u.a));
// printf("%d", sizeof(u.a[4].i));
}
a. 4, 4, 4
b. 40, 4, 4
c. 1, 100, 1
d. 40 400 4 | HCL | 1 |
| Print an integer using only putchar. Try doing it without
using extra storage. | | 1 |
| main()
{
int c[ ]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++) {
printf(" %d ",*c);
++q; }
for(j=0;j<5;j++){
printf(" %d ",*p);
++p; }
} | | 1 |
| Is the following code legal?
struct a
{
int x;
struct a *b;
} | | 1 |
| How to swap two variables, without using third variable ? | HCL | 47 |
| #define square(x) x*x
main()
{
int i;
i = 64/square(4);
printf("%d",i);
} | | 1 |
| void main()
{
int k=ret(sizeof(float));
printf("\n here value is %d",++k);
}
int ret(int ret)
{
ret += 2.5;
return(ret);
} | | 1 |
| main()
{
printf("%d, %d", sizeof('c'), sizeof(100));
}
a. 2, 2
b. 2, 100
c. 4, 100
d. 4, 4 | HCL | 3 |
| |
| For more C Code Interview Questions Click Here |