| Other C Code Interview Questions |
| | | Question | Asked @ | Answers | | | | 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()
{
show();
}
void show()
{
printf("I'm the greatest");
} | | 1 | | What is the main difference between STRUCTURE and UNION? | | 6 | | main()
{
extern i;
printf("%d\n",i);
{
int i=20;
printf("%d\n",i);
}
} | | 1 | | void main()
{
int i=5;
printf("%d",i+++++i);
} | | 1 | | char inputString[100] = {0};
To get string input from the keyboard which one of the
following is better?
1) gets(inputString)
2) fgets(inputString, sizeof(inputString), fp) | | 1 | | write a program to count the number the same
(letter/character foreg: 's') in a given sentence. | | 1 | | main( )
{
char *q;
int j;
for (j=0; j<3; j++) scanf(%s ,(q+j));
for (j=0; j<3; j++) printf(%c ,*(q+j));
for (j=0; j<3; j++) printf(%s ,(q+j));
} | | 1 | | char *someFun1()
{
char temp[ ] = string";
return temp;
}
char *someFun2()
{
char temp[ ] = {s, t,r,i,n,g};
return temp;
}
int main()
{
puts(someFun1());
puts(someFun2());
} | | 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 | | #define FALSE -1
#define TRUE 1
#define NULL 0
main() {
if(NULL)
puts("NULL");
else if(FALSE)
puts("TRUE");
else
puts("FALSE");
} | | 1 | | main()
{
char *str1="abcd";
char str2[]="abcd";
printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd"));
} | | 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 | | 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 | | void main()
{
unsigned giveit=-1;
int gotit;
printf("%u ",++giveit);
printf("%u \n",gotit=--giveit);
} | | 1 | | main()
{
char string[]="Hello World";
display(string);
}
void display(char *string)
{
printf("%s",string);
} | | 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 | | # include <stdio.h>
int one_d[]={1,2,3};
main()
{
int *ptr;
ptr=one_d;
ptr+=3;
printf("%d",*ptr);
} | | 1 | | main()
{
int i=-1;
+i;
printf("i = %d, +i = %d \n",i,+i);
} | | 1 | | main()
{
static int var = 5;
printf("%d ",var--);
if(var)
main();
} | | 1 | | | | For more C Code Interview Questions Click Here |
|