| Other C Code Interview Questions |
| | | Question | Asked @ | Answers | | | | Give a very good method to count the number of ones in a 32
bit number.
(caution: looping through testing each bit is not a solution) | Microsoft | 5 | | How will you print % character?
a. printf(\%)
b. printf(\\%)
c. printf(%%)
d. printf(\%%) | HCL | 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 | | main()
{
char str1[] = {s,o,m,e};
char str2[] = {s,o,m,e,\0};
while (strcmp(str1,str2))
printf(Strings are not equal\n);
} | | 1 | | Write a prog to accept a given string in any order and flash
error if any of the character is different.
For example : If abc is the input then abc, bca, cba, cab
bac are acceptable, but aac or bcd are unacceptable. | Microsoft | 5 | | void main()
{
int *i = 0x400; // i points to the address 400
*i = 0; // set the value of memory location pointed by i;
} | | 1 | | #include"math.h"
void main()
{
printf("Hi everybody");
}
if <stdio.h> will be included then this program will must
compile, but as we know that when we include a header file
in "" then any system defined function find its defination
from all the directrives. So is this code of segment will
compile? If no then why? | | 2 | | main()
{
int i=400,j=300;
printf("%d..%d");
} | | 1 | | main()
{
int i = 0xff ;
printf("\n%d", i<<2);
}
a. 4
b. 512
c. 1020
d. 1024 | HCL | 1 | | #define assert(cond) if(!(cond)) \
(fprintf(stderr, "assertion failed: %s, file %s,
line %d \n",#cond,\
__FILE__,__LINE__), abort())
void main()
{
int i = 10;
if(i==0)
assert(i < 100);
else
printf("This statement becomes else for if in
assert macro");
} | | 1 | | How can u say that a given point is in a triangle?
1. with the co-ordinates of the 3 vertices specified.
2. with only the co-ordinates of the top vertex given. | | 1 | | main()
{
int i=-1;
+i;
printf("i = %d, +i = %d \n",i,+i);
} | | 1 | | main()
{
char *a = "Hello ";
char *b = "World";
clrscr();
printf("%s", strcat(a,b));
}
a. Hello
b. Hello World
c. HelloWorld
d. None of the above | HCL | 1 | | #include<stdio.h>
main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32);
} | | 1 | | How we will connect multiple client ? (without using
fork,thread) | TelDNA | 2 | | main()
{
unsigned int i=10;
while(i-->=0)
printf("%u ",i);
} | | 1 | | main()
{
int c[ ]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++) {
printf(" %d ",*c);
++q; }
for(j=0;j<5;j++){
printf(" %d ",*p);
++p; }
} | | 1 | | main()
{
char *p="GOOD";
char a[ ]="GOOD";
printf("\n sizeof(p) = %d, sizeof(*p) = %d, strlen(p) = %d",
sizeof(p), sizeof(*p), strlen(p));
printf("\n sizeof(a) = %d, strlen(a) = %d",
sizeof(a), strlen(a));
} | | 1 | | main()
{
char not;
not=!2;
printf("%d",not);
} | | 1 | | main()
{
int i=10;
i=!i>14;
Printf ("i=%d",i);
} | | 1 | | | | For more C Code Interview Questions Click Here |
|