| Other C Code Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| main()
{
char *a = "Hello ";
char *b = "World";
clrscr();
printf("%s", strcpy(a,b));
}
a. “Hello”
b. “Hello World”
c. “HelloWorld”
d. None of the above | HCL | 1 |
| 1. const char *a;
2. char* const a;
3. char const *a;
-Differentiate the above declarations. | | 2 |
| #include<conio.h>
main()
{
int x,y=2,z,a;
if(x=y%2) z=2;
a=2;
printf("%d %d ",z,x);
} | | 1 |
| main()
{
char a[4]="HELLO";
printf("%s",a);
} | | 1 |
| main()
{
main();
} | | 1 |
| #include<stdio.h>
main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32);
} | | 1 |
| how to return a multiple value from a function? | Wipro | 5 |
| main()
{
int i = 3;
for (;i++=0;) printf(“%d”,i);
} | | 1 |
| What is the hidden bug with the following statement?
assert(val++ != 0); | | 1 |
| Give a one-line C expression to test whether a number is a
power of 2. | Microsoft | 8 |
| main()
{
char c=' ',x,convert(z);
getc(c);
if((c>='a') && (c<='z'))
x=convert(c);
printf("%c",x);
}
convert(z)
{
return z-32;
} | | 1 |
| main()
{
char *a = "Hello ";
char *b = "World";
clrscr();
printf("%s", strcat(a,b));
}
a. Hello
b. Hello World
c. HelloWorld
d. None of the above | HCL | 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 |
| main()
{
int c = 5;
printf("%d", main||c);
}
a. 1
b. 5
c. 0
d. none of the above | HCL | 1 |
| main( )
{
int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}};
printf(“%u %u %u %d \n”,a,*a,**a,***a);
printf(“%u %u %u %d \n”,a+1,*a+1,**a+1,***a+1);
} | | 1 |
| Finding a number multiplication of 8 with out using
arithmetic operator | NetApp | 8 |
| What is the output for the following program
main()
{
int arr2D[3][3];
printf("%d\n", ((arr2D==* arr2D)&&(* arr2D ==
arr2D[0])) );
} | | 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 |
| main()
{
printf("%d", out);
}
int out=100; | | 1 |
| main()
{
int i=5,j=10;
i=i&=j&&10;
printf("%d %d",i,j);
} | | 1 |
| |
| For more C Code Interview Questions Click Here |