Sei sulla pagina 1di 9

RejoiCe

1. What is the difference between sprintf() and printf() method?


The sprint() method works similar to the printf() method except for one small reason.
printf() method writes the Output onto the Console screen whereas sprintf() method
writes the output to an Array of Characters.
2. When is it required to use an External Data type for a variable?
External variables are also called as Global variables. External should be used if you
need a single variable to be accessed by multiple functions.
3. What is the range of values for an integer in C?
16-bit compiler: -32768 to 32767
32-bit compiler: 2147483648 to 2147483647

4. What is Call By Reference passing method?


In call by reference method, parameters are passed to other methods using their
addresses. Eg.: function1(&a,&b). Here, we are passing the address location number of
a and b to the function1. This strategy manipulates the Actual Arguments.
5. Describe the Advantages of Macros over Variables.
The advantages of using Macros over variables are as follows:
A Compiler can generate faster and compact code for constants that for variables.
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.

DO NOT COPY.
For THIS MATERIAL Call -9705551427 Page 1

RejoiCe
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.
14. What is the difference between && and &?
&& is a Logical Operator and it is pronounced as AND Operator, whereas & is a Bitwise
AND Operator.
15. Describe Comparison Operator and Assignment Operator.
An Assignment Operator is used to assign or set a value to a variable whereas a
Comparison Operator is used to check a condition.
Assignment Operator: =
Comparison Operator: ==

DO NOT COPY.
For THIS MATERIAL Call -9705551427 Page 2

RejoiCe
16. Explain Conditional Operator.
Conditional Operator is also called as Ternary Operator. The Syntax for a Conditional
Operator is: expression 1 ?expression 2 : expression 3
Expression 1 includes the Condition. Depending upon its value, if the Condition
evaluates to be True, expression 2 will be executed and if the Expression 1 evaluates to
be False, expression 3 will be evaluated.
17. What is the difference between Do While Loop and While Loop?
A While Loop checks the Condition before executing the following set of statements
whereas a Do-While Loop first executes the set of statements once and then checks the
condition. In this, statement will be executed at least once even if the Condition
evaluates to be False.
18. What is a break keyword used for?
The keyword break allows us to transfer the Control to the very first statement that
occurs after the current Loop. It therefore takes the Execution Control out of the Loop.
A Break is generally used with IF Blocks and Switches.
19. What is the Advantage of a Switch Case Structure over an IF Block?
A Switch Case Structure leads to a more structured program and the level of
indentation is manageable, more so, if there are multiple statements with each case of
a Switch.
20. Describe Limitations of Switch Case Structure?
A Float expression cannot be tested in a Switch Case.
A Case can never have Variable expression such as c + 5.
It is illegal to use same expressions for multiple cases.
21. What is the significance of a Null Character in String?
A Null Character is represented by \0. It is different than 0. Null Character is a
terminating Character for an Array of Characters i.e., a String. It is the only way to
track the end of a String.
22. What is the difference between function() and function(); ?
function() includes the definition of the function whereas function(); is the declaration
syntax of a function.

DO NOT COPY.
For THIS MATERIAL Call -9705551427 Page 3

RejoiCe
23. What is the role of a return statement?
On executing the return statement, it immediately transfers the control back to the
Calling function.
It returns the value present in the parentheses after return statement to the calling
function.
24. Explain Automatic Storage Class.
Syntax: auto int a;
Storage: Memory
Life: Till the control remains within the block in which the variable is defined.
Default Initial Value: Garbage Value
Scope: Local to the block in which variable is initialized
25. What is the difference between scanf() and gets() methods?
scanf() method cannot accept Multi-Word Strings (that includes a Space character)
whereas gets() method can help to accept Multi-Word Strings.
26. Explain Calling Convention in user defined functions?
It describes primarily two things:
The order in which the arguments are passed to the function.
It also mentions which function performs the cleanup of variables when the control
returns from the function.
The most commonly used convention is Standard Calling Convention.
27. What is Call By Value passing method?
In call by value method, parameters are passed to other methods using their values.
Eg.: function1(a,b)
Here, we are passing values of a and b to the function1.
28. What is a De-Referencing Operator?
A De-Referencing Operator is denoted by an Asterisk *. It is used to store the Address
of an Identifier in C programming.
29. Describe Storage Classes in C Programming Language.
The Storage Classes are as follows:
Automatic Storage Class

DO NOT COPY.
For THIS MATERIAL Call -9705551427 Page 4

RejoiCe
Register Storage Class
Static Storage Class
External Storage Class
30. Explain Register Storage Class.
Syntax: register int a;
Storage: CPU registers
Life: Till the control remains within the block in which the variable is defined.
Default Initial Value: Garbage value
Scope: Local to the block in which variable is initialized
31. What is the difference between getch() and getche() methods?
Both these methods allows the user to read a single character the instant it is typed
without waiting for a Enter key to be pressed. However, in getche() method, the
character is echoed after it is typed whereas in getch() method, no Echo of character is
there.
32. When is it required to use a Static Data type for a variable?
A Static storage class should be used only when you want the value of a variable to be
persistent between different functions of the same program
33. What is the difference between getchar() and fgetchar() methods?
The major difference between the two is that getchar() is a Macro while fgetchar() is a
Function.
34. Explain Static Storage Class.
Syntax: static int a
Storage: Memory
Life: Value persists between different functions
Default Initial Value: Zero
Scope: Local to the block in which variable is initialized
35. When is it required to use an Auto Data type for a variable?
This is probably the most common data type used for any variable. The prefix auto is
not mandatory. If you dont have any special need of a variable, automatic storage class
is the one that you should opt for.

DO NOT COPY.
For THIS MATERIAL Call -9705551427 Page 5

RejoiCe
36. What is pragma directive?
This is a special purpose directive that can be used to turn on or off certain features. It
can help you to terminate the Warnings or any other errors. There are numerous
pragma directives available in C and these are as follows:
#pragma startup
#pragma exit
#pragma warn
37. When is it required to use a Register Data type for a variable?
Since there are few CPU registers available in the memory, register storage class should
be used only when a variable is being used very often
38. Describe the Steps in the Building Process of a C Program.
A C Program is executed with the following steps:
C Source Code File
Expanded Source Code
Assembly Code
Linking Object Code of other Libraries
Executable Code
39. Describe the Operations that can be performed on a Pointer.
The Operations that can be executed using a Pointer in C are as follows:
Addition of a Number to Pointer
Subtraction of a Number from a Pointer
Subtraction of one Pointer from another
Comparison of Two pointer variables
40. Explain External Storage Class.
Syntax: extern int a;
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

DO NOT COPY.
For THIS MATERIAL Call -9705551427 Page 6

RejoiCe
(\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

DO NOT COPY.
For THIS MATERIAL Call -9705551427 Page 7

RejoiCe
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 aUndef Directive. Suppose, if you want to Undefine a Macro that
has been previously defined, you can use the following syntax:
#undefmacro_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.

DO NOT COPY.
For THIS MATERIAL Call -9705551427 Page 8

RejoiCe
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.

DO NOT COPY.
For THIS MATERIAL Call -9705551427 Page 9

Potrebbero piacerti anche