Professional Documents
Culture Documents
There is always a risk that a variable may inadvertently get manipulated in the
program.
6. What is the difference between || and |?
|| is a Logical Operator and it is pronounced as OR Operator, whereas | is a Bitwise OR
Operator.
7. What is a continue keyword used for?
The Continue keyword allows us to transfer the program control back to the very first
Line of the current Loop thereby bypassing the next statements after the Keyword. A
Continue is usually associated with IF Block.
8. How can you make scanf() method accept Multi-Word Strings?
Scanf() function accepts a single string by default. However, a scanf() method can
accept Multi-Word Strings by using the following method:
scanf(%[^\n]s,str);
This way a scanf() method takes in input until an Enter Key is Hit.
9. What is the difference between A and A?
A is a Character Constant whereas A is a String Constant.
10. Does Linux Ubuntu supports the Header file conio.h?
No, the GCC Library in Linux Ubuntu does not contain definitions for conio.h header file.
11. What is the Format specifier or accessing Address using Pointers in
Windows and Linux?
Address Access Specifier in Windows: %u
Address Access Specifier in Linux: %p
12. Describe Modulus Operator?
Modulus Operator is used to fetch the Remainder value on dividing one Integer with
another Integer. Modulus operator cannot work with Float values. Eg.: 10%2=0
13. Is an Else Block necessary for a Corresponding if Block?
No, an If Block is generally independent of an Else Block. An Else Block is used only
when a Conditional Approach is to be used.
Storage: Memory
Life: As long as program doesnt stop execution
Default Initial Value: Zero
Scope: Global
41. What is a String?
A String is a One Dimensional Array of Characters that is terminated by a Null Character
(\0).
Eg.: char name[]=thecrazyprogrammer;
42. What is a NULL Pointer?
A NULL Pointer is a special reserved value of a Pointer. A Null Pointer therefore, points
to Nothing. It doesnt have any Address assigned to it at the time of declaration. Hence,
when a Pointer has NULL value, it is not pointing to anywhere. A NULL Pointer is useful
when you dont have any location address to be assigned to the pointer at the time of
Declaration.
43. Are 0 and \0 same? If not, explain.
No, 0 and \0 are different. ASCII Value of \0 is 0 whereas that of 0 is 48. \0 is a
terminating character normally used in Strings. Its the only way that functions within a
string can know where the String ends. \0 is a single character.
44. What is the difference between char const *p and const char* p ?
In char const *p, pointer p is constant. Therefore, it is not possible to make p point to
another location. However, you can modify the value of the Character referenced by p.
In const char* p, the character referred by p is a constant and therefore it is not
possible to change the value of p. However, it is possible to make p point to another
location.
45. What is the primary difference between a Declaration and a Definition?
While declaring a variable, we only specify the Data Type associated to it. Theres no
memory allocation at this point. However, when we define a Variable into the system,
an initial value is thereby assigned to the variable and theres memory allocation given
to that particular variable.
46. What is ferror() method used for?
ferror() method is a Standard Library Function. It signifies errors that occurs during a
File Write or Read Operation. It returns 0 if the Read/Write Operation is successful and
a Non-Zero value in case of a failure.
47. What is a Void Pointer?
A Void Pointer is a specific type of Pointer that points to the address of a data that does
may have any specific data type associated with it. A Void pointer is also known as a
Generic Pointer. A void pointer is declared like a normal pointer, using the void keyword
as the pointers type.
48. What is #undef Directive?
Sometimes, it is needed to modify a pre-defined name to be undefined for different
reasons. This undefining is without deleting that name from the name. This can be
established by using a Undef Directive. Suppose, if you want to Undefine a Macro that
has been previously defined, you can use the following syntax:
#undef macro_name
49. How can we refer to the Base Address of a 1D Array?
The following methods would work to access the Base Address of an Array:
*num
*(num+0)
50. What is modular programming approach?
Modular programming is the process of breaking down a program into parts so as to
reduce the complexity of a large program. Such parts are nown as Functions. Each
function performs a particular task and is generally interconnected to convey data
between other functions of the same program.
51. Explain the types of Errors in C Programming.
Run Time Errors:
These errors are usually caught by the compilers and occur due to illegal operations
performed within a program such as Dividing an Integer by Zero, Unavailability of
Memory Space and others. These errors terminate the program abruptly.
Compile Time Errors:
Compilation Errors are those that occurs at the Compilation Time of a program. These
errors are further divided into:
Semantic Errors
These errors occur due to undefined operations such as illegal assignment as this
x+y=z.
Syntax Errors
These errors occur if we dont follow the guidelines and rules prescribed by that
particular language.
Logical Errors
Logical errors are most difficult to debug as these are not usually caught by the
Compiler. These generally occur due to Algorithm and Logic issues within the program.
52. What is recursion?
When a Function calls itself again and again, it is called a recursive function. The
Function calls itself till a particular condition does not evaluates to False. Recursion can
be used to replace complex nesting code by dividing the problem into same problem of
its sub-type.
53. What is a Dangling Pointer?
A Dangling Pointer occurs during Destruction of an Object when an object that has an
incoming reference that is de-allocated or deleted without modifying the value of the
Pointer. This is done to make the Pointer still point to the Memory location of the deallocated memory.
54. What is the difference between char str[]=Interview and char
*p=Interview?
Char *p=Interview
In this case, p acts as a Pointer to a Constant String.
Char str[]=Interview
In this case, str acts as a Constant Pointer to a String.
So this was the list of some important C interview questions and answers. If you found
any information incorrect or missing in above list then please mention it by commenting
below.