Top 10 C Programming Interview Questions ...

Amelia Oct 20

1501 1 Replies
c++  

1 What are the key features in the C programming language?
2 What are the basic data types associated with C?
3 What is the description for syntax errors?
4 What is the process to create increment and decrement statement in C?
5 What are reserved words with a programming language?
6 What is the explanation for the dangling pointer in C?
7 Describe static function with its usage?
8 What is the difference between abs() and fabs() functions?
9 Describe Wild Pointers in C?
10 What is the difference between ++a and a++?

Answers

1. Portability: It is a platform-independent language.
Modularity: Possibility to break down large programs into small modules.
Flexibility: The possibility of a programmer to control the language.
Speed: C comes with support for system programming and hence it compiles and 
executes with high speed when compared with other high-level languages.
Extensibility: Possibility to add new features by the programmer.

2. Int – Represent the number (integer)
Float – Number with a fraction part.
Double – Double-precision floating-point value
Char – Single character
Void – Special purpose type without any value.

3. The mistakes/errors that occur while creating a program are called syntax errors. 
Misspelled commands or incorrect case commands, an incorrect number of parameters in calling method /function,
 data type mismatches can be identified as common examples for syntax errors.

4.  There are two possible methods to perform this task.

Use increment (++) and decrement (-) operator.
Example When x=4, x++ returns 5 and x- returns 3.

Use conventional + or – sign.
Example When x=4, use x+1 to get 5 and x-1 to get 3.

5. The words that are a part of the standard C language library are called reserved words. 
Those reserved words have special meaning and it is not possible to use them for any activity other than its intended functionality.

Example: void, return int.

6. When there is a pointer pointing to a memory address of any variable, but after some 
time the variable was deleted from the memory location while keeping the pointer pointing to that location is known as a dangling pointer in C.

7. A function, which has a function definition prefixed with a static keyword is defined as a 
static function. The static function should be called within the same source code.

8. Both functions are to retrieve absolute value. abs() is for integer values and fabs() is for 
floating type numbers. Prototype for abs() is under the library file < stdlib.h > and fabs() is under < math.h >.

9. Uninitialized pointers in the C code are known as Wild Pointers. They point to some 
arbitrary memory location and can cause bad program behavior or program crash.

10. ‘++a”  is called prefixed increment and the increment will happen first on a variable. 
‘a++’ is called postfix increment and the increment happens after the value of a variable used for the operations.
Saud Ashfaq 30, Oct 20