MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

C Interview Questions And Answers

C FAQS
Previous Home Next

C Interview Questions And Answers                                  

Q1:What is result of following code?
main() {
char *ch1=“rajesh”;
char *ch2;
ch2=(char*)malloc(20);
memset (ch2, 0, 20);
while(*ch2++ = *ch1++);
printf(“%s\n”,ch2);
}
Ans:empty string.
Q2:What is result of the following code?
main(){
int x=20,y=35;
x=y++ + x++;
y= ++y + ++x;
printf(“%d%d\n”,x,y);
}
Ans : 5794
Q3:What will be printed as the result of the following code?                                                            
main(){
int x=5;
printf(“%d,%d,%d\n”,x,x< <2,x>>2);
}
Ans: 5,20,1

Q4:What will be result of the following code?

#define swap(x,y) x=x+y;y=x-b;x=x-y;
void main(){
int a=5, b=10;
swap (a,b);
printf(“%d %d\n”,a,b);
swap2(a,b);
printf(“%d %d\n”,a,b);
}
int swap2(int x, inty){
int temp;
temp=x;
y=x;
x=temp;
return 0;
}
Ans: 10, 5
10, 5
Q5:What is result of following code?
main(){
char *ptr = ” Hi How r U?”;
*ptr++; printf(“%s\n”,ptr);
ptr++;
printf(“%s\n”,ptr);
}
Ans:Hi How r U?
i How r U?
Q6:What will be result of following code?

main(){
char s1[]=“HI”;
char s2[]= “How r u?”;
printf(“%s”,s1);
}
Ans:Hi

Q7:What will be result of following code?
main(){
char *ch1;
char *ch2;
ch1=(char *)malloc(25);
ch2=(char *)malloc(25);
strcpy(ch1,”Hi How R U”);
strcpy(ch2,“?”);
strcat(ch1,ch2);
printf(“%s”,ch1);
}
Ans:Hi How R U?

 


Q8: The following variable is available in file1.c, who can access it?
static int averg;
Ans: All the functions in the file1.c can access the variable. Because it is global variable.
Q9:What will be the result of the following code?
#define TRUE 1
while(TRUE)
{
printf("Hi how r u?");
}

Ans: Hi how r u?

Q10:What will be output of following code?
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("Ist output:%d\n",x);
x++;
changevalue(x);
printf("IInd output:%d\n",x);
modifyvalue();
printf("IIIrd output:%d\n",x);
}
Ans: Ist output:12 , IInd output:13 , IIIrd output:13