| Other C Code Interview Questions |
| | | Question | Asked @ | Answers | | | | main()
{
char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
} | | 1 | | void main()
{
static int i=5;
if(--i){
main();
printf("%d ",i);
}
} | | 1 | | 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 | | main()
{
int i;
printf("%d",scanf("%d",&i)); // value 10 is given as
input here
} | | 1 | | main()
{
int i=300;
char *ptr = &i;
*++ptr=2;
printf("%d",i);
} | | 1 | | main(){
int a= 0;int b = 20;char x =1;char y =10;
if(a,b,x,y)
printf("hello");
} | | 1 | | Find your day from your DOB? | Microsoft | 12 | | main()
{
int i=400,j=300;
printf("%d..%d");
} | | 1 | | main()
{
int i=10;
i=!i>14;
Printf ("i=%d",i);
} | | 1 | | main()
{
int i=-1;
-i;
printf("i = %d, -i = %d \n",i,-i);
} | | 1 | | main( )
{
int a[2][3][2] = {{{2,4},{7,8},{3,4}},{{2,2},{2,3},{3,4}}};
printf(“%u %u %u %d \n”,a,*a,**a,***a);
printf(“%u %u %u %d \n”,a+1,*a+1,**a+1,***a+1);
} | | 1 | | program to find the roots of a quadratic equation | HP | 3 | | void main()
{
int *mptr, *cptr;
mptr = (int*)malloc(sizeof(int));
printf(“%d”,*mptr);
int *cptr = (int*)calloc(sizeof(int),1);
printf(“%d”,*cptr);
} | | 1 | | Print an integer using only putchar. Try doing it without
using extra storage. | | 1 | | #include<stdio.h>
main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s;
printf("%d",s->x);
printf("%s",s->name);
} | | 1 | | program to find magic aquare using array | HCL | 3 | | void main()
{
int const * p=5;
printf("%d",++(*p));
} | | 1 | | main()
{
int i=-1,j=-1,k=0,l=2,m;
m=i++&&j++&&k++||l++;
printf("%d %d %d %d %d",i,j,k,l,m);
} | | 1 | | Is this code legal?
int *ptr;
ptr = (int *) 0x400; | | 1 | | main()
{
struct date;
struct student
{
char name[30];
struct date dob;
}stud;
struct date
{
int day,month,year;
};
scanf("%s%d%d%d", stud.rollno, &student.dob.day,
&student.dob.month, &student.dob.year);
} | | 1 | | | | For more C Code Interview Questions Click Here |
|