C Language Interview Questions and Answers for Experienced - 8

Question: 36

What is pointer in C?

Pointer is a variable that stores/points the address of another variable. Normal variable stores the value of the variable whereas pointer variable stores the address of the variable.

syntax: data_type * var_name;

Where, * is used to denote that “p” is pointer variable and not a normal variable.

Question: 37

What are the advantages of using typedefs in a program?

The advantages of using typedefs in a program are

It makes writing of complicated declaration a lot easier, which in turn helps in eliminating lot of typographical errors.

It also helps in achieving portability in programs. Suppose there are some data types that are machine dependent and we use typedefs for those data types, then we only need to change typedefs as we move to new machine platform.

Question: 38

Is it possible to write a program without a main() functions?

No, the main functions is mandatory. The execution of all programs begins from the main() function.

Question: 39

What are the different types of errors?

The types of errors are syntax error, logical error, and runtime error.

Syntax error results from the violation of the grammar (syntax) of C language. In the process of syntax errors, the program will not compile.

Logical errors result from the wrong logic that in turn result from the poor understanding of the problem under consideration. Even in the process of logical errors, the program will run but the results will be incorrect. These errors are most difficult to locate particularly if the problem is large and complex.

Runtime errors result either from non availability of the resource required such an attempt to open/read from a non existing data file or memory allocation failure, etc. or an attempt to perform an illegal operation such as division by zero, taking square root or logarithm of a negative number etc. In the presence of these errors, the program will terminate prematurely, i.e., before finishing its intended task. Premature termination is also known as abnormal terminal.

Errors are also known as bugs.

Question: 40

What is debugging?

It is the process of locating and correcting the bugs.

Related Questions