| Other C Code Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| Give a oneline C expression to test whether a number is a
power of 2?
| Motorola | 16 |
| print numbers till we want without using loops or condition
statements like specifically(for,do while, while swiches,
if etc)!
| | 7 |
| print a semicolon using Cprogram without using a semicolon
any where in the C code in ur program!!
| Tata-Elxsi | 19 |
| 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 |
| String reverse with time complexity of n/2 with out using
temporary variable. | NetApp | 8 |
| main()
{
char *cptr,c;
void *vptr,v;
c=10; v=0;
cptr=&c; vptr=&v;
printf("%c%v",c,v);
} | | 1 |
| How to return multiple values from a function?
| | 4 |
| main()
{
int i=5,j=6,z;
printf("%d",i+++j);
} | | 1 |
| typedef struct error{int warning, error, exception;}error;
main()
{
error g1;
g1.error =1;
printf("%d",g1.error);
} | | 1 |
| String copy logic in one line. | NetApp | 9 |
| main()
{
int i=5;
printf("%d",++i++);
} | | 1 |
| how to return a multiple value from a function? | Wipro | 2 |
| main()
{
int i = 258;
int *iPtr = &i;
printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) );
} | | 1 |
| #include<stdio.h>
main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
} | | 1 |
| How to access command-line arguments? | | 4 |
| 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=0;
while(+(+i--)!=0)
i-=i++;
printf("%d",i);
} | | 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 is the output of the program given below
main()
{
signed char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
} | | 1 |
| main()
{
char p[ ]="%d\n";
p[1] = 'c';
printf(p,65);
} | | 1 |
| |
| For more C Code Interview Questions Click Here |