This article is designed to prepare you for the most common C programming questions you may be asked in an interview. At the bottom of the C programming interview questions, answers are also provided so that you can answer the interviewers’ questions.
List of C Programming Interview Questions
- Q1) What is the difference between Call by Value and Call by Reference?
- Q2) In C programming, how do you insert quote characters (‘and “) into the output screen?
- Q3) Differentiate Source Codes from Object Codes.
- Q4) What is the use of a ‘\0’ character?
- Q5) Compare and contrast compilers from interpreters.
- Q6) Can I use the “int” data type to store the value 32768? Why?
- Q7) What are variables and in what way is it different from constants?
- Q8) What is wrong with this statement? scanf(“%d”,whatnumber);
- Q9) What are preprocessor directives?
- Q10) What does the format %10.2 mean when included in a print statement?
C Programming Interview Questions and Answers
Q1) What is the difference between Call by Value and Call by Reference?
When using Call by Value, you are sending the value of a variable as a parameter to a function, whereas Call by Reference sends the address of the variable. Also, under Call by Value, the value in the parameter is not affected by whatever operation that takes place, while in the case of Call by Reference, values can be affected by the process within the function.
Q2) In C programming, how do you insert quote characters (‘and “) into the output screen?
This is a common problem for beginners because quotes are normally part of a printf statement. To insert the quote character as part of the output, use the format specifiers \'(for single quote), and \” (for double quote).
Q3) Differentiate Source Codes from Object Codes.
Source codes are codes that were written by the programmer. It is made up of the commands and other English-like keywords that are supposed to instruct the computer what to do. However, computers would not be able to understand source codes. Therefore, source codes are compiled using a compiler. The resulting outputs are object codes, which are in a format that can be understood by the computer processor. In C programming, source codes are saved with the file extension .C, while object codes are saved with the file extension .OBJ
Q4) What is the use of a ‘\0’ character?
It is referred to as a terminating null character and is used primarily to show the end of a string value.
Q5) Compare and contrast compilers from interpreters.
Compilers and interpreters often deal with how program codes are executed. Interpreters execute program codes one line at a time, while compilers take the program as a whole and convert it into object code, before executing it. The key difference here is that in the case of interpreters, a program may encounter syntax errors in the middle of execution, and will stop from there. On the other hand, compilers check the syntax of the entire program and will only proceed to execution when no syntax errors are found.
Q6) Can I use the “int” data type to store the value 32768? Why?
No. “int” data type is capable of storing values from -32768 to 32767. To store 32768, you can use “long int” instead.
Q7) What are variables and in what way is it different from constants?
Values held by a variable can be altered throughout the program and can be used in most operations and computations. Constants are given values at one time only, placed at the beginning of a program. This value is not altered in the program. For example, you can be assigned a constant named Pl and give it a value of 3.1415. You can then use it as Pl in the program, instead of having to write 3.1415 each time you need it.
Q8) What is wrong with this statement? scanf(“%d”,whatnumber);
An ampersand & symbol must be placed before the variable name whatnumber. Placing & means whatever integer value is entered by the user is stored at the “address” of the variable name. This is a common mistake for programmers, often leading to logical errors.
Q9) What are preprocessor directives?
Preprocessor directives are placed at the beginning of every C program. This is where library files are specified, which would depend on what functions are to be used in the program. Another use of preprocessor directives is the declaration of constants. Preprocessor directives begin with the # symbol.
Q10) What does the format %10.2 mean when included in a print statement?
This format is used for two things: to set the number of spaces allotted for the output number and to set the number of decimal places. The number before the decimal point is for the allotted space, in this case, it would allot 10 spaces for the output number. If the number of space occupied by the output number is less than 10, additional space characters will be inserted before the actual output number. The number after the decimal point sets the number of decimal places, in this case, it’s 2 decimal spaces.
Visit Our Website Today For More Technical Interview Questions and Answers.
Also Read Data Structures and Algorithms Interview Questions With Answers | 20 Essential Python Interview Questions And Answers. | The most frequently asked web developer interview questions | Java Interview Questions and Answers