Вы находитесь на странице: 1из 6

10/24/13

List of all C interview questions in this blog | Interview Mantra

List of all C interview questions in this blog


by S R I DHA R JA MMA LA MA DA K A on N OV E MB E R 1 8 , 2 008

17 Votes

All the Material available on this site is absolutely Free! Please support us by subscribing via email.
Enter y our email below

Subscribe
We do not sell y our em ail or spam .

Go to Downloads Page to download all the C interview question and answers as a pdf. 1. What does a static variable mean? 2. What is a pointer? 3. What is a structure? 4. How to print a pattern as shown below?
1 23 456 7891 0

5. How to swap two numbers using bitwise operators? 6. What is recursion? Write a program using recursion (factorial)? 7. To which numbering system, can the binary number 1101100100111100 be easily converted to? 8. What are the differences between structures and unions? 9. What are the advantages of using unions? 10. What is scope & storage allocation of global and extern variables? Explain with an example. 11. What is scope & storage allocation of static, local and register variables? Explain with an example. 12. What is Pass by Value? Write a C program showing this concept. 13. What is Pass by Reference? Write a C program showing this concept. 14. What is an Enumeration? 15. What is the use of typedef? 16. What are register variables? What are advantages of using register variables? 17. What are storage memory, default value, scope and life of Automatic and Register storage class? 18. What are storage memory, default value, scope and life of Static and External storage class? 19. What are the advantages of using pointers in a program? 20. Which bitwise operator is suitable for checking whether a particular bit is ON or OFF? 21. Which bit wise operator is suitable for turning OFF a particular bit in a number? 22. What do the c and v in argc and argv stand for? Explain their purpose? 23. What are the differences between malloc() and calloc()? 24. Where are the auto variables stored? 25. Out of fgets( ) and gets( ) which function is safer to use and why? 26. How can you increase the size of a dynamically allocated array?

www.interviewmantra.net/2008/11/list-of-all-c-interview-questions-in.html

1/6

10/24/13

List of all C interview questions in this blog | Interview Mantra


27. Write a program to check whether a given number is even or odd. 28. Write a program to find the greatest of three numbers. 29. Write a program to check whether a given number is a prime. 30. Write a program to find the greatest among ten numbers. 31. Write a program to swap two numbers using a temporary variable. 32. Write a program to swap two numbers without using a temporary variable. 33. How to swap two numbers using bitwise operators? 34. Write a program to check whether a given number is a palindromic number. 35. Write a program to check whether a given string is a palindrome. 36. Write a program in C to print Hello World without using semicolon anywhere in the code. 37. Write a program in C to print a semicolon without using a semicolon anywhere in the code. 38. Write a program in C to delete a specific line from a text file. 39. Write a program in C to replace a specified line in a text file. 40. Write a program in C to find the number of lines in a text file. 41. (i)What are the differences between the C statements below: char *str = Hello;char arr[] = Hello; (ii)Whether following statements get complied or not? Explain each statement. arr++; *(arr + 1) = s; printf(%s,arr); 42. Explain the variable assignment in the declaration int *(*p[10])(char *, char *); 43. What is the value of sizeof(a) /sizeof(char *) in C code snippet below char *a[4]= {sridhar,raghava,shashi,srikanth}; explain 44. Write a program in C that returns 3 numbers from a function. 45. In below code snippet: struct Date { int yr; int day; int month; } date1,date2; date1.yr = 2004; date1.day = 4; date1.month = 12; Write a function in C that assign values to date2. Arguments to the function must be pointers to the structure Date and integer variables date, month, year. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. What are header files? Are functions declared or defined in header files ? What is the difference between the functions strdup and strcpy in C? What is difference between for loop and while loop in C language? Write down the equivalent pointer expression for referring the same element as a[i][j][k][l]. Which one is equivalent to multiplying an unsigned int by 2, left shifting by 1 or right shifting by 1? Declare an array of three function pointers where each function receives two integers and returns float. Write a program to compare two strings without using strcmp() function. Write a function to concatenate two strings without using strcat function. Write a program to generate the fibonacci series

Write a C program which asks the user for a number between 1 to 9 and shows the number. If the user inputs a number out of the specified range, the program should show an error and prompt the user for a valid input. 56. Write a program to display the multiplication table of a given number. 57. Write C program to print the following pattern:

www.interviewmantra.net/2008/11/list-of-all-c-interview-questions-in.html

2/6

10/24/13

List of all C interview questions in this blog | Interview Mantra


1 22 333 4444 55555

58. Write C program to print the following pattern:


1 121 12321 1234321 123454321

59. Write a C program to display the following format:


ab 15 24 33 42 51 -

60. Write a C program to display the following format:


n o .s u m 1 1 2 3 3 6 4 1 0 5 1 5 -

61. What is the purpose of main() function? 62. What is the difference between declaring a variable and defining a variable? 63. What are the differences between formal arguments and actual arguments? 64. What is difference between getchar and scanf functions for reading strings? 65. What is difference between break and continue statements? C Interview Questions with solutions ebook as a pdf/doc/html

About t he Aut hor: Sridhar Jam m alam adaka is the Editor of Interv iew Mantra. He is a student pursuing m asters in International Institute of Inform ation Technology . With ov er 4 y ears of IT experience, he is obsessed with software program m ing and com puter technologies. He lov es to see a software com e to life in its dev elopm ent life cy cle. He is a person who defies "m ob m entality " and a deeply spiritual and a strong believ er of m oral v alues and righteousness. Through this website, he wishes to gather a large com m unity of aspiring engineers, entrepreneurs and professionals from all parts of the globe. You can connect with him on Facebook ht t p://www.facebook.com/sridhar.j

Advertise

Register domain name free Facebook

Advertising Websites

Register domain names Mantra 1

Business Solution

Download All

12 comments Leave a message...


Best Community S hraddha
4 years ago

Share

www.interviewmantra.net/2008/11/list-of-all-c-interview-questions-in.html

3/6

10/24/13

S hraddha

List of all C interview questions in this blog | Interview Mantra

I was asked at the TCS interview: How will you write a macro for declaring a 4byte number while using an 8bit processor? I do know there's typecasting involved but I stumbled while writing the syntax. Please ans this if u know Sridhar. Regards, Shraddha
13 Gopi Reply
a year ago

Share

I was asked in the interview to print 0 1111 22222222 3333 4


2 Reply naren Share

Gopi 11 months ago

Hi gopi, This should print the above pattern., /*pattern printing 0 1111 22222222 3333 4*/ printf("\n0"); for ( i = 0; i <= n; i ++) {
see more

Reply

Share

Avatar

P at hak ay us hi2612

a year ago

plz print this pattern: 4444 333 and 22 1


1 Reply Share

7777 555 33 1

s hubham gujarwas ia

Pathakayushi2612 5 months ago

******FOR FIRST ONE******* #include<stdio.h> #include<math.h> int main() { int i,j; printf("\n a program to print a pattern:"); printf("\n********************************\n\n\n"); for(i=4;i>0;i--) { for(j=0;j<i;j++) #include<stdio.h="" *************for="" getch();=""

www.interviewmantra.net/2008/11/list-of-all-c-interview-questions-in.html

4/6

10/24/13

for(j=0;j<i;j++) #include<stdio.h="" *************for="" getch();=""


see more

List of all C interview questions in this blog | Interview Mantra

Reply

Share

Avatar

Zy t haar

a year ago

you are the best man!!!! :-)


Reply Share

Avatar

Jdfh

2 years ago

not that much collection of good codes and problems .


Reply Share

Avatar

V vvraman88

2 years ago

i want code for the following ***** **** *** ** * please mail me the code my id is : vvvraman88@gmail.com
Reply Idk Lol Share
Vvvraman88 2 years ago

#include<stdio.h> #include<conio.h> void main() { int i,j,s,nos=0; for(i=5 ; i>=1 ; i--) { for(s=nos ; s>=1 ; s--) { printf(" "); } for(j=1 ; j<=i ; j++) { printf("*"); } printf("\n"); nos++; } getch(); }</conio.h></stdio.h>
Reply Share

Avatar

May a

3 years ago

Loved your questions ! thanks for putting them together.


Reply Share

Avatar

A s hok

4 years ago

there are 2 cases : 1. return 0; & return 1; at a time OR 2.return 1,0; these are valid ! then please give me difference between both and when are they used?
Reply admin Share
Ashok 4 years ago

@Ashok, The value returned from the main() is sent to the host environment or the parent process that calls your program. The parent might need to follow different paths depending on the success or failure of your program. Hence, one must always return a value from the program that returns its status back to the callee. return 0 means that the program was executed successfully, return 1 means that the program was terminated abruptly. 1 is returned when something goes wrong in the program execution.

www.interviewmantra.net/2008/11/list-of-all-c-interview-questions-in.html

5/6

10/24/13

List of all C interview questions in this blog | Interview Mantra


return 2 is same as return 1. For that matter, any non-zero value. Does this answer your question? Feel free to ask.
Reply Share

Su b s cri b e

Ad d D i s q u s to yo u r s i te

P R E V I OU S P OS T:

C interview questions recursion, unions vs structures, storage allocation of

variables.
N E X T P OS T:

C interview puzzles semicolon programs, delete or replace a line in a text file

www.interviewmantra.net/2008/11/list-of-all-c-interview-questions-in.html

6/6

Вам также может понравиться