| Other C Code Interview Questions |
| | | Question | Asked @ | Answers | | | | 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 | | main(){
int a= 0;int b = 20;char x =1;char y =10;
if(a,b,x,y)
printf("hello");
} | | 1 | | Given an array of characters which form a sentence of words,
give an efficient algorithm to reverse the order of the words
(not characters) in it. | Wipro | 2 | | void ( * abc( int, void ( *def) () ) ) (); | | 1 | | write a program to Insert in a sorted list | Microsoft | 4 | | main()
{
int c=- -2;
printf("c=%d",c);
} | | 1 | | main()
{
signed int bit=512, mBit;
{
mBit = ~bit;
bit = bit & ~bit ;
printf("%d %d", bit, mBit);
}
}
a. 0, 0
b. 0, 513
c. 512, 0
d. 0, -513 | HCL | 1 | | How do you write a program which produces its own source
code as its output?
| | 7 | | void main ()
{
int x = 10;
printf ("x = %d, y = %d", x,--x++);
}
a. 10, 10
b. 10, 9
c. 10, 11
d. none of the above | HCL | 1 | | void main()
{
int i=5;
printf("%d",i+++++i);
} | | 1 | | 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 | | enum colors {BLACK,BLUE,GREEN}
main()
{
printf("%d..%d..%d",BLACK,BLUE,GREEN);
return(1);
} | | 1 | | main()
{
char *p = “ayqm”;
char c;
c = ++*p++;
printf(“%c”,c);
} | | 1 | | #define prod(a,b) a*b
main()
{
int x=3,y=4;
printf("%d",prod(x+2,y-1));
} | | 1 | | Is the following code legal?
typedef struct a aType;
struct a
{
int x;
aType *b;
}; | | 1 | | Given n nodes. Find the number of different structural
binary trees that can be formed using the nodes. | Aricent | 7 | | main()
{
static int a[3][3]={1,2,3,4,5,6,7,8,9};
int i,j;
static *p[]={a,a+1,a+2};
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
printf("%d\t%d\t%d\t%d\n",*(*(p+i)+j),
*(*(j+p)+i),*(*(i+p)+j),*(*(p+j)+i));
}
} | | 1 | | main()
{
int i=-1;
+i;
printf("i = %d, +i = %d \n",i,+i);
} | | 1 | | Write a routine that prints out a 2-D array in spiral order | Microsoft | 2 | | write the function. if all the character in string B appear in
string A, return true, otherwise return false. | Google | 10 | | | | For more C Code Interview Questions Click Here |
|