| Other C Code Interview Questions |
| | | Question | Asked @ | Answers | | | | Is this code legal?
int *ptr;
ptr = (int *) 0x400; | | 1 | | 1)
int i=5;
j=i++ + i++ + i++;
printf("%d",j);This code gives the answer 15.But if we
replace the value of the j then anser is different?why?
2)int i=5;
printf("%d",i++ + i++ + i++);
this givs 18. | Infosys | 6 | | void main()
{
while(1){
if(printf("%d",printf("%d")))
break;
else
continue;
}
} | | 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 | | main()
{
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 | | void main()
{
static int i;
while(i<=10)
(i>2)?i++:i--;
printf(“%d”, i);
} | | 1 | | Finding a number which was log of base 2 | NetApp | 1 | | program to find magic aquare using array | HCL | 3 | | main()
{
int i=_l_abc(10);
printf("%d\n",--i);
}
int _l_abc(int i)
{
return(i++);
} | | 1 | | main()
{
int i=5,j=10;
i=i&=j&&10;
printf("%d %d",i,j);
} | | 1 | | 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()
{
float f=5,g=10;
enum{i=10,j=20,k=50};
printf("%d\n",++k);
printf("%f\n",f<<2);
printf("%lf\n",f%g);
printf("%lf\n",fmod(f,g));
} | | 1 | | main()
{
int i;
clrscr();
for(i=0;i<5;i++)
{
printf("%d\n", 1L << i);
}
}
a. 5, 4, 3, 2, 1
b. 0, 1, 2, 3, 4
c. 0, 1, 2, 4, 8
d. 1, 2, 4, 8, 16 | HCL | 1 | | #define FALSE -1
#define TRUE 1
#define NULL 0
main() {
if(NULL)
puts("NULL");
else if(FALSE)
puts("TRUE");
else
puts("FALSE");
} | | 1 | | Is the following code legal?
typedef struct a
{
int x;
aType *b;
}aType | | 1 | | #define prod(a,b) a*b
main()
{
int x=3,y=4;
printf("%d",prod(x+2,y-1));
} | | 1 | | print a semicolon using Cprogram without using a semicolon
any where in the C code in ur program!!
| Tata-Elxsi | 19 | | #include<stdio.h>
main()
{
int a[2][2][2] = { {10,2,3,4}, {5,6,7,8} };
int *p,*q;
p=&a[2][2][2];
*q=***a;
printf("%d..%d",*p,*q);
} | | 1 | | How will you print % character?
a. printf(“\%”)
b. printf(“\\%”)
c. printf(“%%”)
d. printf(“\%%”) | HCL | 1 | | how to delete an element in an array
| | 1 | | | | For more C Code Interview Questions Click Here |
|