| Other C Code Interview Questions |
| | | Question | Asked @ | Answers | | | | main()
{
int i = 0xff ;
printf("\n%d", i<<2);
}
a. 4
b. 512
c. 1020
d. 1024 | HCL | 1 | | main( )
{
static int a[ ] = {0,1,2,3,4};
int *p[ ] = {a,a+1,a+2,a+3,a+4};
int **ptr = p;
ptr++;
printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr);
*ptr++;
printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr);
*++ptr;
printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr);
++*ptr;
printf(“\n %d %d %d”, ptr-p, *ptr-a, **ptr);
} | | 1 | | what will be the position of the file marker?
a: fseek(ptr,0,SEEK_SET);
b: fseek(ptr,0,SEEK_CUR); | | 1 | | Write a routine that prints out a 2-D array in spiral order | Microsoft | 2 | | int i,j;
for(i=0;i<=10;i++)
{
j+=5;
assert(i<5);
} | | 1 | | #if something == 0
int some=0;
#endif
main()
{
int thing = 0;
printf("%d %d\n", some ,thing);
} | | 1 | | void main()
{
int i;
char a[]="\0";
if(printf("%s\n",a))
printf("Ok here \n");
else
printf("Forget it\n");
} | | 1 | | main()
{
int i=5,j=6,z;
printf("%d",i+++j);
} | | 1 | | int swap(int *a,int *b)
{
*a=*a+*b;*b=*a-*b;*a=*a-*b;
}
main()
{
int x=10,y=20;
swap(&x,&y);
printf("x= %d y = %d\n",x,y);
} | | 1 | | main()
{
show();
}
void show()
{
printf("I'm the greatest");
} | | 1 | | Give a oneline C expression to test whether a number is a
power of 2?
| Motorola | 16 | | You are given any character string. Find the number of sets
of vowels that come in the order of aeiou in the given
string. For eg., let the given string be DIPLOMATIC. The
answer returned must be "The number of sets is 2" and "The
sets are "IO and AI". Vowels that form a singleton set must
be neglected. Try to post the program executable in gcc or
g++ or in java. | | 3 | | how to return a multiple value from a function? | Wipro | 5 | | void main()
{
while(1){
if(printf("%d",printf("%d")))
break;
else
continue;
}
} | | 1 | | main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
} | | 1 | | main()
{
int x=5;
clrscr();
for(;x==0;x--) {
printf("x=%d\n”", x--);
}
}
a. 4, 3, 2, 1, 0
b. 1, 2, 3, 4, 5
c. 0, 1, 2, 3, 4
d. none of the above | HCL | 1 | | void main()
{
int *mptr, *cptr;
mptr = (int*)malloc(sizeof(int));
printf(“%d”,*mptr);
int *cptr = (int*)calloc(sizeof(int),1);
printf(“%d”,*cptr);
} | | 1 | | #include <stdio.h>
main()
{
char * str = "hello";
char * ptr = str;
char least = 127;
while (*ptr++)
least = (*ptr<least ) ?*ptr :least;
printf("%d",least);
} | | 1 | | main()
{
char *str1="abcd";
char str2[]="abcd";
printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd"));
} | | 1 | | main()
{
int c=- -2;
printf("c=%d",c);
} | | 1 | | | | For more C Code Interview Questions Click Here |
|