C interview questions with answers and explanation for freshers

(1)
#include"stdio.h"
void main(){
long double a=55555;
clrscr();
printf("%.2LE,%.2Le",a);
getch();
}
What will be output if you will execute above code?
(a) 5.56e+04, 5.56E+04
(b) 5.6e+04, 5.6E+04
(c) 5.56E+04, 5.56e+04
(d)Compiler error.
(e)None of the above.
(2)
#include"stdio.h"
void main(){
signed a=5;
unsigned b=5;
clrscr();
if(a==b)
printf("EQUAL");
else
printf("UNEQUAL");
getch();
}
What will be output if you will execute above code?
(a) EQUAL
(b) UNEQUAL
(c) Print nothing
(d) Compiler error.
(e) None of the above
(3)
#include"stdio.h"
void main(){
fputs("STANDARD PRINTER DEVICE",stdprn);
getch();
}
What will be output if you will execute above code?
(a) STANDARD PRINTER DEVICE (on the paper)
(b) STANDARD PRINTER DEVICE (on the standard output device)
(c) Print nothing
(d)Compiler error.
(e)None of the above.
(4)
#include"stdio.h"
void main(){
char a='\';
clrscr();
printf("%c",a);
getch();
}
What will be output if you will execute above code?
(a)\
(b)\\
(c)Print nothing
(d)Compiler error.
(e)None of the above.
(5)
#include"stdio.h"
void main(){
char a='\7',b='\8';
clrscr();
printf("%d %d",a,b);
getch();
}
What will be output if you will execute above code?
(a) 7 8
(b) 7 56
(c) 55 56
(d) Compiler error.
(e) None of the above.
(6)
#include"stdio.h"
void main(){
char a='\10';
char *str1="cquestion",*str2="bank";
clrscr();
printf("%s%c%s",str1,a,str2);
getch();
}
What will be output if you will execute above code?
(a) cquestionbank
(b) cquestioba
(c) cquestiobank
(d) Compiler error.
(e) None of the above.
(7)
#include"stdio.h"
void main(){
char a='\11';
char *str1="cquestion",*str2="bank";
clrscr();
printf("%d",printf("%s%c%s",str1,a,str2));
getch();
}
What will be output if you will execute above code?
(a) cquestionbank
(b) cquestionbank14
(c) cquestion bank14
(d)Compiler error.
(e)None of the above.
(8)
#include"stdio.h"
void main(){
char a='\12';
char *str1="cquestion",*str2="bank";
clrscr();
printf("%s%c%s",str1,a,str2);
getch();
}
What will be output if you will execute above code?
(a) cquestionbank
(b) cquestion
bank
(c) bankcquestion
(d) Compiler error.
(e) None of the above.
(9)
#include"stdio.h"
void main(){
char a='\377';
clrscr();
printf(2+"%d%o",a);
getch();
}
What will be output if you will execute above code?
(a) 379
(b) 377
(c) 177777
(d) Compiler error.
(e) None of the above.
(10)
#include"stdio.h"
void main(){
char a='\378';
clrscr();
printf("%o",a);
getch();
}
What will be output if you will execute above code?
(a) 177777
(b) 378
(c) 377
(d) Compiler error.
(e) None of the above.
(11)
void main(){
int goto=5;
printf("%d",goto);
getch()
}
What will be output if you will execute above code?
(a)5
(b)10
(c)15
(d)Compiler error.
(e)None of the above.
(12)
void main(){
long int 1a=5l;
printf("%ld",1a);
getch();
}
What will be output if you will execute above code?
(a)5
(b)51
(c)235
(d)Compiler error.
(e)None of the above.
(13)
void main(){
Char * emp name=”raja”;
printf("%s",emp name);
getch();
}
What will be output if you will execute above code?
(a)raja
(b)null
(c)Address of variable emp name
(d)Compiler error.
(e)None of the above.
(14)
void main(){
long int new=5l;
printf("%ld",new);
getch();
}
What will be output if you will execute above code?
(a)5
(b)10
(c)15
(d)Compiler error.
(e)None of the above.
(15)
void main(){
long int _=5l;
printf("%ld",_);
getch();
}
What will be output if you will execute above code?
(a)5
(b)10
(c)15
(d)Compiler error.
(e)None of the above.
(16)
void main(){
char * __WORLD__="world";
clrscr();
printf("%s ",__WORLD__);
getch();
}
What will be output if you will execute above code?
(a)world
(b)worl
(c)null
(d)Compiler error.
(e)None of the above.
(17)
void main(){
char * __TIME__="world";
clrscr();
printf("%s ",__TIME__);
getch();
}
What will be output if you will execute above code?
(a)world
(b)Current time
(c)null
(d)Compiler error.
(e)None of the above.
(18)
void main(){
long int a;
(float)a=6.5;
printf("%f",a);
getch();
}
What will be output if you will execute above code?
(a)6
(b)7
(c)6.5
(d)Compiler error.
(e)None of the above.
(19)
void main(){
long int a,b=10;
++a=b++;
printf("%d %d",a,b);
getch();
}
What will be output if you will execute above code?
(a)10 10
(b)11 11
(c)0 11
(d)Compiler error.
(e)None of the above.
(20)
void main(){
long int a,b=5;;
~a=++b + ++b + ++b;
printf("%d %d",++a,++b);
getch();
}
What will be output if you will execute above code?
(a) -10 9
(b) -11 8
(c) -11 9
(d) Compiler error.
(e) None of the above.
(21)
void main(){
int x;
int y;
x+y=10;
x=3;
printf("%d",y);
getch();
}
What will be output if you will execute above code?
(a)0
(b)7
(c)10
(d)Compiler error.
(e)None of the above.
(22)
void main(){
int x=5;
int y=10;
&x=y;
printf("%d %d",x,y);
getch();
}
What will be output if you will execute above code?
(a)5 10
(b)10 5
(c)10 10
(d)Compiler error.
(e)None of the above.
(23)
void main(){
const a=10;
a=~a;
printf("%d",a);
getch();
}
What will be output if you will execute above code?
(a) 10
(b)-11
(c)-10
(d)Compiler error.
(e)None of the above.
(24)
void main(){
const _=10;
int *p=&_;
printf("%d",*p);
getch();
}
What will be output if you will execute above code?
(a)Address of variable _
(b)20
(c)10
(d)Compiler error.
(e)None of the above.
(25)
void main(){
const int *a=12;
a++;
clrscr();
printf("%d",a);
getch();
}
What will be output if you will execute above code?
(a)12
(b)garbage value
(c)13
(d)Compiler error.
(e)None of the above.
output: garbage value
(26) What will be output of the following program ?
void main(){
const int *a=(const int * )12;
*a=(const int *)25;
clrscr();
printf("%d",a);
getch();
}
What will be output if you will execute above code?
(a)12
(b)25
(c)Address of variable a
(d)Compiler error.
(e)None of the above.
(27)
#include"stdio.h"
void main(){
char a='\15';
char *str1="cquestion",*str2="bank";
clrscr();
printf("%s%c%s",str1,a,str2);
getch();
}
What will be output if you will execute above code?
(a) bankstion
(b)cquestionbank
(c)bankcquestion
(d)Compiler error.
(e)None of the above.
Answer:
1. (c)
2. (a)
3. (a)
4. (d)
5. (b)
6. (c)
7. (c)
8. (b)
9. (c)
10. (d)
11. (d)
12. (d)
13. (d)
14. (a)
15. (a)
16. (a)
17. (d)
18. (d)
19. (d)
20. (d)
21. (d)
22. (d)
23. (d)
24. (c)
25. (b)
26. (d)
27. (a)
Explanation:
1. (c) %e or %E represent print the number in exponential format.
%e means output has small letter e.
%E means output has capital letter e.
2. (a) before any arithmetic operation small data type convert into higher data type i.e.signedto unsigned.
3. (a) PRINT IN CONNECTED PRINTER DEVICE, OTHERWISE
TURBO C WILL BE HANGED FOR SEARCHING OF PRINTER IN THE SYSTEM.
4. (d) Character is \ has special meaning in c programming.
e.g.
‘\0’ represents octal character.
‘\n’ represents new line character. So we cannot use ‘\’ directly.
5. (b) 8 is not octal digit. octal digits are(0,1,2,3,4,5,6,7).
So ‘\7’ is octal 7
‘\8’ some special character constant.
6. (c) ‘\10’ represent octal 10 i.e. decimal 8 which is ASCII code of backspaces (only one character)
7. (c) ‘\11’ represent octal 11 i.e. decimal 9 which is ASCII code of blank space.
8. (b) ‘\12’ represent octal 12 i.e. decimal 10 which is ASCII code of new line character i.e. send the cursor to next line
9. (c) ‘\377’ is octal character constant.
%o is used to print octal number system.
10. (d) Highest possible character constant is ‘\377’ which is
Equivalent to decimal 255.
11. (d) invalid variable name. goto is keyword in c.
12. (d) invalid variable name. Variable name must star from either alphabet or
under score.
13. (d) invalid variable name. Except underscore there should not be any special character in name of variable event blank space.
14. (a) We can use c++ keyword in variable name in c programming.(But should not use ,why ?)
15. (a) Under score is valid keyword in c.
16. (a) __WORLD__ is valid identifier in c programming language.
But we should not write variable name in the forma like __xyx__,
__TIME__. Why ?
17. (d) __TIME__ is valid identifier in c programming language but it is
Predefine global identifier .So a variable not should not be global
Identifier like __TIME__,__DATE___,__FILE__ etc.
18. (d) After applying any operator in variable name it always give a value.
(type): urinary type casting operator is not exception for this.
It is similar to write
3456=5
It is invalid c statement. Because left side of assignment operator must
Be a variable not any constant.
19. (d) After applying any operator in variable name it always give a value.
(type): urinary type casting operator is not exception for this.
It is similar to write
3456=5
It is invalid c statement. Because left side of assignment operator must
Be a variable not any constant.
20. (d) After applying any operator in variable name it always give a value.
(type): urinary type casting operator is not exception for this.
It is similar to write
3456=5
It is invalid c statement. Because left side of assignment operator must be a variable not any constant.
21. (d) After applying any operator in variable name it always give a value.
(type): urinary type casting operator is not exception for this.
It is similar to write
3456=5
It is invalid c statement. Because left side of assignment operator must be a variable not any constant.
22. (d) After applying any operator in variable name it always give a value.
(type): urinary type casting operator is not exception for this.
It is similar to write
3456=5
It is invalid c statement. Because left side of assignment operator must be a variable not any constant.
23. (d) we Cannot modify a const object.
24. (c) We can assign address of const object to its pointer.
Underscore is valid variable name.
25. (b) Explanation: Here address of variable a is constant not variable a. So we can modify variable a. Initial value of auto type data is garbage.
26. (d) we Cannot modify a const object.
Here address of variable a is constant not variable a.
27. (a) ‘\11’ represent octal 11 i.e. decimal 9 which is ASCII code of carriage return (return to first position of that line)

14 comments:

Adi said...

accept string from user of different lengths and sort it in ascending order lengthwise without built in function

Adi said...

accept string from user of different lengths and sort it in ascending order lengthwise without built in function

Adi said...

accept string from user of different lengths and sort it in ascending order lengthwise without built in function

Knowledge said...

Thank a lot. You have done excellent job. I enjoyed your blog . Nice efforts
Data Science Certification in Hyderabad

Institute said...

Wow, happy to see this awesome post. I hope this think help any newbie for their awesome work and by the way thanks for share this awesomeness, i thought this was a pretty interesting read when it comes to this topic. Thank you..
Artificial Intelligence Course

Data Science Courses said...

Awesome article. I enjoyed reading your articles. this can be really a good scan for me. wanting forward to reading new articles. maintain the nice work!
Data Science Courses in Bangalore

Emerging Technologies said...

I need to thank you for this very good read and i have bookmarked to check out new things from your post. Thank you very much for sharing such a useful article and will definitely saved and revisit your site.
Data Science Course

Education said...

Your site is truly cool and this is an extraordinary moving article and If it's not too much trouble share more like that. Thank You..
Digital Marketing Course in Hyderabad

Business Analytics said...

I am sure it will help many people. Keep up the good work. It's very compelling and I enjoyed browsing the entire blog.
Business Analytics Course in Bangalore

AI Courses said...
This comment has been removed by the author.
AI Courses said...


What an incredible message this is. Truly one of the best posts I have ever seen in my life. Wow, keep it up.
AI Courses in Bangalore

Data Analytics Course said...

Excellent Blog! I would like to thank you for the efforts you have made in writing this post. Gained lots of knowledge.
Data Analytics Course

Tech Institute said...

I want to thank you for your efforts in writing this article. The information provided was very useful.
Data Science Certification Bangalore

kumal kumar said...

I really enjoyed reading your blog. It was very well written and easy to understand. Unlike other blogs that I have read which are actually not very good. Thank you so much!
Iot Course in Bangalore