C computer language programming / technical interview questions and answers with programs detailes solutions free online for various top IT companies in India and US. freshers and on campus interviews and placement papers.
. What will print out?
main()
{
char *k1="hitechskill.com";
char *k2;
k2=(char*)malloc(20);
memset (k2, 0, 20);
while(*k2++ = *k1++);
printf("%s\n",k2);
}
Answer:empty string.
2.What will be printed as the result of the operation below:
main()
{
int a=20,b=35;
a=b++ + a++;
b= ++b + ++a;
printf("%d%d\n",a,b);
}
Answer : 5794
3.What will be printed as the result of the operation below:
main()
{
int a=5;
printf(?%d,%d,%d\n?,a,a< <2,a>>2);
}
Answer: 5,20,1
4.What will be printed as the result of the operation below:
#define swap(a,b) a=a+b;b=a-b;a=a-b;
void main()
{
int m=5, n=10;
swap (m,n);
printf("%d %d\n",m,n);
swap2(m,n);
printf("%d %d\n",m,n);
}
int swap2(int x, int y)
{
int temp;
temp=x;
y=x;
x=temp;
return 0;
}
Answer: 10, 5
10, 5
5.What will be printed as the result of the operation below:
main()
{
char *ptr = "SC Systems";
*pt++; printf("%s\n",pt);
pt++;
printf("%s\n",pt);
}
Answer: SC Systems
C Systems
6.What will be printed as the result of the operation below:
main()
{
char s1[]="SC";
char s2[]= "Systems";
printf("%s",s1);
}
Answer: SC
7.What will be printed as the result of the operation below:
main()
{
char *ptr1;
char *ptr2;
ptr1=(char *)malloc(25);
ptr2=(char *)malloc(25);
strcpy(ptr1,"SC");
strcpy(ptr2,"Systems");
strcat(ptr1,ptr2);
printf("%s",ptr1);
}
Answer: SCSystems
8.The following variable is available in file1.c, who can access it?:
static int average;
Answer: all the functions in the file1.c can access the variable.
9.What will be the result of the following code?
#define TRUE 0 // some code
while(TRUE)
{
// some code
}
Answer: This will not go into the loop as TRUE is defined as 0.
10.What will be printed as the result of the operation below:
int x;
int modifyvalue()
{
return(x+=10);
}
int changevalue(int x)
{
return(x+=1);
}
void main()
{
int x=10;
x++;
changevalue(x);
x++;
modifyvalue();
printf("First output:%d\n",x);
x++;
changevalue(x);
printf("Second output:%d\n",x);
modifyvalue();
printf("Third output:%d\n",x);
}
Answer: 12 , 13 , 13
11.What will be printed as the result of the operation below:
main()
{
int x=10, y=15;
x = x++;
y = ++y;
printf("%d %d\n",x,y);
}
Answer: 11, 16
12.What will be printed as the result of the operation below:
main()
{
int a=0;
if(a==0)
printf("Cisco Systems\n");
printf("Cisco Systems\n");
}
Answer: Two lines with "Cisco Systems" will be printed.
No comments:
Post a Comment