C Language frequently asked questions
1) Difference between function and procedure
- A function must return a value whereas procedures may or may not return a value.
- Functions can be called from procedures whereas procedures cannot be called from Functions.
2) Difference between low level and high-level language
- A low-level language is machine dependent whereas high-level language is machine dependent
- Low-level language are in a binary form whereas high-level language is written in English
- A low-level language is difficult to learn whereas high-level language can be learned easily
3) Difference between definition and declaration
- The declaration means it tells the compiler what is the name of the variable, type of value it can hold and the initial value it takes.
- The definition tells where the variable gets stored, the memory of the variable will be allocated during definition.
4) What is a null pointer
- It is a pointer which points to nothing. If we don’t have an address to assign to a pointer then we can use Null
5) What is a void pointer
- A void pointer points to some data location in storage which doesn't have any specific data type.
6) What is a dangling pointer
- When a pointer is pointing towards a memory which was deleted or freed is known as a dangling pointer.
7) Difference between float and double
- A float has 6 decimal digits precision whereas double has 15 decimal points precision.
- Float takes only 4 bytes of storage whereas double takes 8 bytes of storage.
8) Difference between structure and union
- In structure, each member gets different memory whereas in union the total memory space allocated is equal to the sum of sizes of all members.
- Unions stores different data type in the same memory location.
9) Difference between a++ and ++a
- a++ is postfix and ++a is prefix. The prefix returns the value of a variable after it has been incremented, whereas postfix returns the value of a variable before it has been incremented.
10) What is function prototyping
- It tells the return type of the function that will return and also tells the number of arguments passed to the function.
- It also tells the order in which the arguments are passed to the function.
11) What is a nested loop
- One loop inside another loop is known as a nested loop. We can put a for loop inside a for loop or we can keep for loop inside a while loop.
12) Difference between int and long int
- The size of an integer is 4 bytes where long takes 8 bytes. So the range of int and long int are different.
13) What are storage classes in c
- Storage classes are used to tell the scope, visibility and lifetime. Storage classes are of four types. They are automatic, extern, register and static.
14) What are lvalue and rvalue
- An expression that appears on the left side of the assignment expression is known as lvalue and that appears on the right side of the assignment expression is known as rvalue.
15) What is a preprocessor
- It instructs the compiler to do pre-processing before the actual compilation is done.
- All preprocess commands with #(hash symbol).
16) What are command line arguments
- To pass some values from the command line to the C program when it is executed. The argument inside the main function is known as command line arguments.
- argc counts the number of arguments and argv[ ] is a pointer array.
17) What is a conditional operator
- Conditional value returns a value if the condition is true and returns another value if the condition is false.
Syntax: (Condition ?true value:false value)
If the condition is true it returns true value else it returns a false value.
18) What is an enumerated data type
- It is an user-defined data type. By using enumeration we can assign names to integral constants to make the program easy to read
19) Difference between variable and constant
- A variable can be modified at the time of execution whereas a constant cannot be modified at the time of execution. In simple variable values can be altered at execution whereas constant cannot.
20) Call by value and call by reference
- Call by value: Values of actual parameters are copied to function’s formal parameters so there will be no effect on actual variables.
- Call by reference: Actual and formal parameter refers to the same memory location. There will be an effect on actual variables.
21) What are macros
- A particular code is replaced by the value of a macro. It is defined by using a #define directive.
- There are two types of macros 1. Object-like Macros 2. Function-like Macros
22) What is a recursion
- Recursion is a process of function calling itself. In a program, if a function is calling the same function again and again, is known as recursion.
- By using the recursing algorithm Towers of Hanoi, tree traversals problems can be solved.
23) Can a function return multiple values
- C doesn't allow a function to return multiple values. In a C program function will return only one single value.
24) What is a pointer
- A pointer is a variable which stores the address of another variable. By using pointers we can allocate memory dynamically.
- Pointers are especially used for dynamic memory allocation and Data structures in C language.
To learn more about C language - click here