| Other C Code Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| how to return a multiple value from a function? | Wipro | 2 |
| main()
{
int i=-1;
-i;
printf("i = %d, -i = %d \n",i,-i);
} | | 1 |
| write a program to Insert in a sorted list | Microsoft | 4 |
| Program to find the largest sum of contiguous integers in
the array. O(n) | | 7 |
| main()
{
if ((1||0) && (0||1))
{
printf("OK I am done.");
}
else
{
printf("OK I am gone.");
}
}
a. OK I am done
b. OK I am gone
c. compile error
d. none of the above | HCL | 1 |
| Derive expression for converting RGB color parameters to
HSV values | | 1 |
| main()
{
while (strcmp(“some”,”some\0”))
printf(“Strings are not equal\n”);
} | | 1 |
| main()
{
extern out;
printf("%d", out);
}
int out=100; | | 1 |
| Is the following code legal?
void main()
{
typedef struct a aType;
aType someVariable;
struct a
{
int x;
aType *b;
};
} | | 1 |
| #ifdef something
int some=0;
#endif
main()
{
int thing = 0;
printf("%d %d\n", some ,thing);
} | | 1 |
| Is there any difference between the two declarations,
1. int foo(int *arr[]) and
2. int foo(int *arr[2]) | | 1 |
| How to swap two variables, without using third variable ? | HCL | 47 |
| main()
{
int a=2,*f1,*f2;
f1=f2=&a;
*f2+=*f2+=a+=2.5;
printf("\n%d %d %d",a,*f1,*f2);
} | | 1 |
| How to return multiple values from a function?
| | 4 |
| main()
{
float i=1.5;
switch(i)
{
case 1: printf("1");
case 2: printf("2");
default : printf("0");
}
} | | 1 |
| main()
{
char not;
not=!2;
printf("%d",not);
} | | 1 |
| main()
{
char *p = “ayqm”;
printf(“%c”,++*(p++));
} | TCS | 2 |
| 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 |
| In the following pgm add a stmt in the function fun such
that the address of
'a' gets stored in 'j'.
main(){
int * j;
void fun(int **);
fun(&j);
}
void fun(int **k) {
int a =0;
/* add a stmt here*/
} | | 1 |
| main()
{
char *p;
p="Hello";
printf("%c\n",*&*p);
} | | 1 |
| |
| For more C Code Interview Questions Click Here |