C Programming theory Questions and answers – Part 1

1. Explain what is pointer?
Answer : Pointers is a variable that stores or points the address of another variable. A Pointer in C is used to allocate memory dynamically, i.e. at run time. The pointer variable can be of any of the data type such as int, float, char, double, short etc.

2. What are header files and what are its uses in C programming?
Answer : Header files are also known as library files. They contain two essential things: the definitions and prototypes of functions being used in a program. Simply put, commands that you use in C programming are actually functions that are defined from within each header files. Each header file contains a set of functions. For example: stdio.h is a header file that contains definition and prototypes of commands like printf and scanf.

3. What is the difference between structured oriented, object oriented and non-structure oriented programming language?
Answer : Structured oriented programming language
In this type of language, large programs are divided into small programs called functions.
Prime focus is on functions and procedures that operate on data
Data moves freely around the systems from one function to another
Program structure follows “Top Down Approach”
Object oriented programming language
In this type of language, programs are divided into objects
Prime focus is on the data that is being operated and not on the functions or procedures
Data is hidden and cannot be accessed by external functions
Program structure follows “Bottom UP Approach”
Non-structure oriented programming language
There is no specific structure for programming this language.

4. What is generic pointer in C?
Answer : In C void* acts as a generic pointer. When other pointer types are assigned to generic pointer, conversions are applied automatically (implicit conversion).

5. What is the difference between an enumeration and a set of pre-processor # defines?
Answer : There is hardly any difference between the two, except that #defines has a global effect (throughout the file) whereas an enumeration can have an effect local to the block if desired. Some advantages of enumeration are that the numeric values are automatically assigned whereas in #define we have to explicitly define them. A disadvantage is that we have no control over the size of enumeration variables.

test1

test1

Comments are closed here.