| Other C Code Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| main(int argc, char *argv[])
{
(main && argc) ? main(argc-1, NULL) : return 0;
}
a. Runtime error.
b. Compile error. Illegal syntax
c. Gets into Infinite loop
d. None of the above | HCL | 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.
| Microsoft | 7 |
| what will be the position of the file marker?
a: fseek(ptr,0,SEEK_SET);
b: fseek(ptr,0,SEEK_CUR); | | 1 |
| main()
{
int y;
scanf("%d",&y); // input given is 2000
if( (y%4==0 && y%100 != 0) || y%100 == 0 )
printf("%d is a leap year");
else
printf("%d is not a leap year");
} | | 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 |
| Is the following code legal?
void main()
{
typedef struct a aType;
aType someVariable;
struct a
{
int x;
aType *b;
};
} | | 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 |
| 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 |
| To Write a C program to remove the repeated characters in
the entered expression or in entered characters(i.e)
removing duplicates. | Synergy | 2 |
| enum colors {BLACK,BLUE,GREEN}
main()
{
printf("%d..%d..%d",BLACK,BLUE,GREEN);
return(1);
} | | 1 |
| main()
{
int i=_l_abc(10);
printf("%d\n",--i);
}
int _l_abc(int i)
{
return(i++);
} | | 1 |
| How do you sort a Linked List (singly connected) in O(n)
please mail to pawan.10k@gmail.com if u can find an
anser...i m desperate to knw... | Oracle | 3 |
| Extend the sutherland-hodgman clipping algorithm to clip
three-dimensional planes against a regular paralleiepiped | IBM | 1 |
| void main()
{
int i;
char a[]="\0";
if(printf("%s\n",a))
printf("Ok here \n");
else
printf("Forget it\n");
} | | 1 |
| Write, efficient code for extracting unique elements from
a sorted list of array.
e.g. (1, 1, 3, 3, 3, 5, 5, 5, 9, 9, 9, 9) -> (1, 3, 5, 9).
| Microsoft | 10 |
| How to access command-line arguments? | | 4 |
| There were 10 records stored in “somefile.dat” but the
following program printed 11 names. What went wrong?
void main()
{
struct student
{
char name[30], rollno[6];
}stud;
FILE *fp = fopen(“somefile.dat”,”r”);
while(!feof(fp))
{
fread(&stud, sizeof(stud), 1 , fp);
puts(stud.name);
}
} | | 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 |
| Given only putchar (no sprintf, itoa, etc.) write a routine
putlong that prints out an unsigned long in decimal. | | 5 |
| |
| For more C Code Interview Questions Click Here |