| Other C Code Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| how to delete an element in an array
| | 1 |
| How to return multiple values from a function?
| | 4 |
| 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()
{
char a[4]="HELL";
printf("%s",a);
} | Wipro | 1 |
| main()
{
int i = 258;
int *iPtr = &i;
printf("%d %d", *((char*)iPtr), *((char*)iPtr+1) );
} | | 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 |
| 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()
{
printf("\nab");
printf("\bsi");
printf("\rha");
} | | 1 |
| main()
{
int k=1;
printf("%d==1 is ""%s",k,k==1?"TRUE":"FALSE");
} | | 1 |
| Is the following statement a declaration/definition. Find
what does it mean?
int (*x)[10]; | | 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 |
| main()
{
char *str1="abcd";
char str2[]="abcd";
printf("%d %d %d",sizeof(str1),sizeof(str2),sizeof("abcd"));
} | | 1 |
| What is the output of the program given below
main()
{
signed char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
} | | 1 |
| #include<stdio.h>
main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
} | | 1 |
| main()
{
int c=- -2;
printf("c=%d",c);
} | | 1 |
| main()
{
extern int i;
i=20;
printf("%d",i);
} | | 1 |
| main()
{
41printf("%p",main);
}8 | | 1 |
| #include<stdio.h>
main()
{
int i=1,j=2;
switch(i)
{
case 1: printf("GOOD");
break;
case j: printf("BAD");
break;
}
} | | 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 |
| #define max 5
#define int arr1[max]
main()
{
typedef char arr2[max];
arr1 list={0,1,2,3,4};
arr2 name="name";
printf("%d %s",list[0],name);
} | | 1 |
| |
| For more C Code Interview Questions Click Here |