In almost every MNC organization, C Programming Interview Questions have become an integral part of the interview process. This tutorial focuses on the most frequently asked and most recently revised questions in most recent interviews. This article also includes a combination of basic and advanced C programming interview questions.
Q1. Why C is called a Structured language?
Ans. C is called a structured language. The essential feature of structured language is that we should divide the program into small modules that perform a specific task. With the use of local variables available within the functions (i.e. small modules), we can divide the program and hide the usage of the variable from the rest of the program. These functions hide the rest of the program’s information and instructions, thus making it a structured language.
Q1.2 Why is C known as a mother language?
Ans. The C is often referred to as the mother language of all the modern programming languages because C language was originally developed for writing operating systems. Unix Kernel, compilers, JVMs etc. C++, Java, JavaScript, Go, Rust, Limbo, LPC, C#, PHP, Python, Perl, Verilog, and other languages developed after C have all substantially formed from it. Programming principles including variables, data types, loops, arrays, functions, file handling, dynamic memory allocation, and pointers were all introduced by the C programming language, and the majority of these concepts are still utilized in many modern programming languages like C++, Java, and C#.
Q 1.3 Who is the founder of C language?
Ans. Dennis Ritchie.
Q1.4 When was C language developed?
Ans. Bell Laboratories of AT&T developed the C language in 1972.
Q2. Why C is called a Middle-level language?
Ans. C is called a middle-level language. It is binding the gap between machine level language and more conventional high-level language. It allows manipulation of bits, bytes and addresses, which helps in-system programming. Also, large numbers of operators, keywords and library functions available in C help us extend the Programming methodology.
Q3. What are the characteristics of the C language?
Ans. The characteristics of C language:
• Simplicity: The structure feature help to make code look simple.
• Clarity: The keywords, operators and library functions available resemble common English words, thus improving the clarity.
• Portability: It can easily be made to run on different computers.
• Modularity: The programs made can be divided into small modules, thus increasing the understand ability of the program.
• Efficiency: This feature of C to deal with memory management helps save memory and improve efficiency.
Q4. What are the advantages of the C language?
• Portability: Programs made in C can be made to run on different computers or operating systems. Thus making it a system-independent language.
• Structured Approach: The dividing of large programs into smaller modules and using local variables help divide programs and make their code easy to understand. It also helps to hide data or information from ordinary user.
• It helps to bridge the gap between machine level language and high-level language. We can operate on bits, bytes and addresses, i.e. system program in C.
Q5. Give the full forms of these abbreviations? ANSI, EBCDIC, ASCII
Ans. ANSI – American National Standards Institute
EBCDIC – Extended Binary-Coded Decimal Interchange Code.
ASCII – American Standard Code for Information Interchange
Q6. Why is C called a ‘Case-Sensitive’ language?
Ans. C is called a Case Sensitive language because the variables used in uppercase letters have a different meaning, and variables used in lowercase letters have a different meaning. It can be considered as a disadvantage of C.
Q7. Why is C named so?
Ans. C is named to present it as the successor of the B language.
Q8. Who developed B language?
Ans. Ken Thompson in 1970 developed B for the first UNIX system on the DEC PDP- 7 computer.
Q9. What are the limitations of C?
Ans. There is no uniformity in associativity and no direct I/O facility.
Q10. What is the latest version of C?
Ans. C99 is the current version of C. The character set is changed by supporting Unicode characters in this version. It includes additional data types such as bool, complex, variable-length arrays, variable structure members, and some more new syntax. Since there is a substantial change, most compilers have not yet implemented C99. The specification of the new C99 may be obtained from the ISO web site.
Q11. What is ‘Top down’ programming?
Ans. The method in which the programming strategy is established, and then the syntactic details are considered for making the program, is called ‘top down’ programming.
Q12. What is Pseudocode?
Ans. Pseudocode is a programming analysis tool that is used for planning program logic. ‘Pseudo’ means imitation or false, and ‘code’ refers to instructions written in a Programming language. Pseudocode, therefore, is an imitation of actual computer instructions.
Q13. What is an algorithm?
Ans. The algorithm is the steps written in simple English languages, which helps design an informal outline.
Q14. What is ‘bottom up’ programming?
Ans. The program modules’ technique is written before the actual program in the overall programming process is called the bottom-up approach of the programming program.
Q15. Why did every program begin with the main ( ) function?
Ans. The program begins with the main() function because this is from where the compiler knows that program execution starts.
Q16. Which is better, Compiler or Interpreter?
Ans. The compilers are usually compact, and they generate object programs that are small and highly efficient. The interpreters are less efficient though they are easier to use when developing a new program. Programmers usually begin with an interpreter and switch to a compiler once the program is
debugged.
Q17. Is turning a source file into an executable file a two-step process?
Ans. Yes, firstly, the program has complied to the object file with (.OBJ) extension, and then they are linked, i.e. (.OBJ) file is turned to (.EXE) file. Linking combines more than one object files into a single
executable file.
Q18. Why a program consists of more than one object file?
Ans. Library functions written in a program comes in an object-file form and must be combined with the user-written program.
Q19. What is the user screen area?
Ans. The user screen area is Rows = 80
Columns = 25
Q20. What is the difference between opening Turbo C and Borland C compilers?
Ans. While opening the turbo C compiler, we have to write tc, and while opening the Borland C compiler, we have to write bc.
Q21. What is a program name extension in the case of C language?
Ans. Program_Name.C
Q22. Name any five C compilers.
Ans. 1. Turbo C 2. Microsoft C 3. Quick C 4. ANSI C 5. Power C.
Q23. How are comments included in a C program?
Ans. Single line or multiline comments are included between I* and *I. Nested comments are not allowed in ANSI C. For example, /* FINDING THE AREA OF CIRCLE */
Q24. What is modular programming?
Ans. If a program is large, it is subdivided into several smaller programs called modules or subprograms. If a complex problem is solved using more modules, this approach is known as modular programming.
Q25. What are the various forms in which main() can be written?
Ans.
1. main() {………..}
2. void main() {………..}
3. int main( ) {…….; return 0;}
4. main(int argc, char *argv)
Q26. What are the two basic types of constants?
Ans. Primary constants and secondary constants. Primary constants include integer, floating and character constants. Secondary constants include array, pointer, structure, union etc.
Q27. What is the difference between ‘B’ and “B”?
Ans. ‘B’ is a character constant that contains only ‘B’. “B” is a string constant containing two characters, constant ‘B’ and ‘\0’.
Q28. How do we calculate the data range of a particular data type?
Ans. For an x-bit, data range may fall within -2x-1 to +2x-1-1. In the case of unsigned integer quantity, the data range may be from 0 to 2x-1.
E.g. In case of integers, x = 16
So Range is -216-1 to +216-1-1
i.e. -215 to +215-1 i.e. -32768 to 32767
Q29. What will be the Output?
Ans. As we know, the range of integer is till 32767, so adding I will make it out of range, and it will start backwards so that the Output will be -32768.
Q30. What will be the equivalent C expression of
Ans.
(1) a – (a/ (a-x)) + b
(2) 1 + (1/(a + (1/a))) + B
(3) ((1 – X)/(1 + X))/((1+ y)/(1-y))
(4) (l/r) = (1/r1) + (1/r2)
Q31. Name the scalar data type in C.
Ans. int. char. float, and double.
Q32. What are qualifiers in C?
Ans. Qualifiers or modifiers are identifiers that may precede the scalar data types (except float) to specify the number of bits used for representing the respective type of data in memory. The qualifiers in C are short, long, signed, and unsigned.
Q33. Name the type specifiers in C.
Ans. char, int, float, double, short, long, signed and unsigned.
Q34. List the printable escape sequences.
Ans. \\, \”,\’,and\?
Q35. List white space characters in C.
Ans. Blank space, newline, horizontal tab, vertical tab, carriage return and form feed are white space characters.
Q36. What is a statement terminator? What is a separator?
Ans. Each statement is ended with a semicolon, so a semicolon is a statement terminator, whereas a white space character or a comment is a separator used to separate tokens.
Q37. What are lvalue and rvalue?
Ans. Each variable has two values: the left value and the right value, whose short names are lvalue and rvalue. The lvalue denotes an object that is the address of the data object. The rvalue is the value residing in that address. An lvalue represents a memory location where a value may be stored; it denotes an object that refers to a storage location of the data object. The term lvalue is used, based on the principle of its appearance, on the left side of an assignment statement. Consider the following statements:
int a, b;
a = 6;
b = a;
In the first assignment statement, a is an lvalue. Hence a is treated as a name for a particular memory location, and the value 6 is stored in that memory location. 1n the second assignment statement, a is not an lvalue, and hence the value stored in the memory location is referred to, by a. Thus, in some
statements, an operand must be an lvalue. If an lvalue appears in any other context, it is replaced by the value stored in that memory location.
Q38. What do you understand by Precision?
Ans. The Precision is expressed as a number of significant digits. For example, the Precision of 6 digits means that type’s binary representation is precise enough to store a real number of six decimal digits. Its conversion back into a six-digit decimal yields the original six digits.
Q39. What is the formatted and unformatted I/O function?
Ans. Formatted I/O function: Formatted functions allow the input to be read from the Keyboard or Output displayed on the VDU to be formatted as per requirements. They usually operate on char, int, float and string. printf () and scanf () are two I/O functions
Unformatted I/O functions: Unformatted functions allow the input to be read from the Keyboard or Output to be displayed on the VDU in the compiler’s format. We cannot change it as per our requirements. They operate on char and strings only. getch (), getche (), getcgar () are I/O functions.
Q39.1 What is the use of printf() and scanf() functions?
Ans. printf(): To print integer, character, float, and string values on the screen, use the printf() function.
The format specifiers are listed below:
%d: In order to print an integer value, a format specifier is necessary.
%s: To print a string, a format specifier is used.
%c: A character value is displayed using this format specifier.
%f: A floating point value is displayed using this format specifier.
scanf(): The user’s input is taken using the scanf() method.
Q40. What are unformatted input library functions available for the character?
Ans. getch(), getchar() , getche().
Q41. Why do we use the (&) operator in the scanf() library function?
Ans. In the case of a scanf(), each variable name must be preceded by an ampersand(&) because the arguments are pointers that indicate where the data items are stored in the computer’s memory.
Q42. What is the importance of the (-ve) sign in printf() statement?
Ans. It helps to display the Output displayed on the screen to be left-justified.
Q43. How does printf() differ from scanf() I/O function?
Ans. printf(): The printf() is an output function used by Compiler. In printf(), the data from memory is printed on the VDU. In printf(), the only variable name is required. We can use escape sequences with it. Eg. printf ( “\n%d”, a);
scanf(): The scanf ( ) is an input function used by C compiler. In scanf(), the data is received in memory through input devices, i.e. Keyboard. In scanf () the address of memory, location is required, given by ampersand(&) used before the variable name. We cannot use escape sequences with it. Eg. scanf (“%d”,&a);
Q44. What will be output of printf (“%7.lf%”, 12 .1);
Ans.
Q45. What happens if decimals to be printed are less than present in the number?
Ans. Then they will be rounded off.
printf (“%7.lf” , 7.678) ;
Here the result is 7.7 as 7.678 is rounded off.
Q46. How will you print the Output? “I said,” Let’s do C !”
Ans. printf (“I said, \ “Let’s do C !\” “);
Q47. What happens when conversion characters are written are different from the data type of the variables specified?
Ans. Garbage Value Printed
Q48. What is difference between getche() and getch()?
Ans. getche(): Library function returns each character typed as soon as it’s typed. It takes no arguments and requires a conio. h header file. It echos the character to the screen; therefore, we have e in getch(). In the case of getch(), the character is not echoed. Rest it is same as getche().
Q49. What is difference between scanf() and gets()?
Ans. When we are using scanf (“%s”, a), where a is an array. Now we enter “Dinesh Thakur”, only “Dinesh” will be the value assigned to character array a. Thus, we are not ab1e to print the required Output.
But if we are using gets(a), we will print the required Output.
Q50. What do you mean by Interactive Programming?
Ans. In interactive programming, the computer interacts with the user through input and output statement, i.e. the program should contain more input-output bound instructions then CPU bound instructions.
Q51. Can we use escape sequences with scant()?
Ans. No.
Q52. How will you replace blank spaces with zeros using output functions in the case of integer data type?
Ans. In printf, the expressions go into a stack from right to left and where they are evaluated and finally popped off the stack.
(b) Hello world
Q53. What is a header file?
Ans. Header files provide the definitions and declarations for the library functions. Thus, each header file contains the library functions along with the necessary declarations. For example, stdio.h,math.h.,stdlib.h, string.h etc.
Q54. What is the effect of using \n in scanf()?
Ans. It assigns the number of characters reads so far to the matching argument given in the address list.
Q55. What is EOF? How is it entered from the Keyboard?
Ans. EOF refers to the end of the file. It is entered as Ctrl+z in the DOS environment and Ctrl+d in the UNIX environment.
Q56. What is a place holder?
Ans. A place-holder is a conversion specification that tells how to interpret the next input field. A complete place holder may include a suppression character and field width as given below :
%[suppression_char] [fieldwidth] conversion_char
For example, scanf (“%2d%*1c”,&x,&y);
Q57. What is the value returned by printf()?
Ans. The printf () function returns the number of characters printed. If an error occurs, it returns a negative value.
Q58. How can you use printf () without a semicolon?
Ans. void main() { if(printf( “Programusing printf without ; “)) }
Q59. Will 44 evaluate to be true or false?
Ans. True, because it evaluates to value other than zero.
Q60. Will 0 evaluate to be true or false?
Ans. False because its value is 0.
Q60.1 What purpose does a static variable in C language?
Ans. These are some applications for static variables:
1. A static variable is one that has been declared as such. The static variable preserves its value across function calls.
2. Static variables are employed since their scope is available throughout the program. As a result, we can access a static variable from anyplace in the program.
3. The static variable is set to zero at the start. When we change the value of a variable, the new value is assigned.
4. The static variable is utilised as a global value shared by all methods.
5. To save memory, the static variable is only initialized once in the memory heap.
Q61. What do you mean by the hierarchy of operators?
Ans. Hierarchy of operators means the order of evaluation of the operators in a given expression.
Eg. d = a + b – c;
d = (a + b) – c; [operation:+]
Q62. What is the difference between associativity and the hierarchy of operators?
Ans. The hierarchy of operators means the order of evaluation of the operators in a given expression. It is referred to in a group of operators. E.g., Unary operators have higher precedence over the arithmetic operators.
Associativity refers to the order of evaluation of the operators in a given group. E.g. Associativity in the case of unary operators is from right to left.
Q63. What value will be assigned to the variable at last when more than one assignments are made?
Ans. Only the last assignment statement will make the assignments to a variable.
main() { int a = 1; a = 2; a = 3; printf ("a=%d",a); Output:a = 3 }
All other assignments would be overwritten.
Q64. How would you assign the same value to a number of variables in single statements?
Ans. Using an assignment statement, X=Y=Z=4;
Q65. Can we reduce an expression to a shorthand expression by changing the position of the operand?
Ans. In some cases, we can and in some cases, we cannot.
Suppose a = b + a which is equivalent to a = a + b
a += b
Similarly is the case for multiplication. It is because these operators follow the associative rule.
But, if a = b – a which is not equivalent to a = a – b
Therefore by changing the position of operands, we don’t get the same results.
Similar is the case for division and modulus operator.
Q66. Can two operators be written together?
Ans. It is not possible in the case of binary operators, but in the case of unary operators (-,!, ~), it can be possible.
Eg. -++a, !(–a), -(++a)
Similarly, the indirection operator(*) can work with other operators.
Q67. What is the primary difference between relational operators and logical operators?
Ans. In relational operators, the operands can have integer, real or character type values and the results are either true or false.
But in logical operators, the operands represent boolean value, i.e. true and false, and the result is also boolean constant.
Q68. When should we use a conditional operator(?:)
Ans. When the true and false part of a condition results in a single statement to be executed, then we use a conditional operator ?:
But, if it results in more than one statement to be executed than we don’t use it, and in that case, the use of an if-else statement is preferred.
Q69. Classify the types of operators based on the number of operands.
Ans.
Unary: The operator that uses a single operand is a unary operator.
Binary: The operator that uses two operands is a binary operator.
Ternary: The operator that uses three operands is a ternary operator.
Q70. What is a modulus operator? What are the restrictions of a modulus operator?
Ans. A modulus operator gives the remainder value. The result of x % y is obtained by (x – (x/y) * y). This operator is applied only to integral operands and cannot be applied to float or double.
Q71. Why a++ executes faster than a+1?
Ans. The expression a++ requires a single machine instruction such as INR to carry out the increment operation whereas, a + 1 requires more instructions to carry out this operation.
Q72. Differentiate between relational and logical expressions.
Ans. The relational expression uses numeric data and relational operators, whereas logical expressions use logical values and logical operators. The logical values may be obtained using relational expressions also. Hence, a logical expression contains relational expressions also whereas, a relational expression contains numeric expressions and not logical expressions.
Q73. What are the assignments possible in C?
Ans. 1. Simple assignment 2. Compound assignment 3. Assignment as expressions
For example,
a = 10; /* Simple assignment */
a += 5; /* Compoundassignment */
a = b = c = 0; /* Assignmentas expression */
Q74. What is an integral promotion?
Ans. An operand in an expression or a statement is converted to a higher rank data type causing upward type conversion. It is known as integral promotion.
Q75. What is downward type conversion?
Ans. If an operand in an expression or a statement is converted to a lower rank data type, it is known as downward type conversion. It may occur when the left-hand side of an assignment has a lower rank data type than the values on the right-hand side.
Q76. What are the exceptions in the evaluation of logica1 expressions involving && and ||?
Ans. If the left operand yields a false value, the right operand is not evaluated by a compiler in a logical expression using &&. If the left operand yields a true value, the right operand is not evaluated by the compiler in a logical expression with the operator ||. If one operand is false in logical AND, the result is false, and if one operand is true in logical OR, the result is true. The operator && and || have left to right associativity. Hence, the left operand is evaluated first and based on the Output, the right operand may or may not be evaluated.
Q77. How can you add two numbers without using the + operator?
Ans.
/* Adding two numbers without using + operator */ #include #include main() { int a =8, b =4,c; This means that the string entered from the standard clrscr(); input device can contain any ASCII character c = a^b; except the newline character. When we press printf("%d",c); (ENTER) the string comes to an end. getch(); }
Q78. What is the importance of braces in conditional statements?
Ans. If the braces are not used, then the C compiler assumes that the programmer only wants the next statement to be executed immediately.
Eg. if (condition) { if (condition) statement 1; statement 1; statement 2; statement 2; }
Here both statements will be executed Here, only statement1 is executed depending depending on the if statement. on if statement2 does not depend on it.
Q79. The various if statement available in C are
Ans.
- Simple if
- if-else statement
- Nested if-else
- else-if Ladder
Q80. Is while loop for exit controlled or entry controlled loop? Why?
Ans. An entry controlled loop is because the test condition is tested before starting the loop’s execution. If the conditions are not satisfied, then the body of the loop will not be executed, and control will be transferred out of the loop.
Q81. How will you make for loop infinite loop?
Ans. for(;;) is an infinite loop. Thus, there is no initialization, no incrementation, and no expression testing, for the loop becomes an infinite loop.
Q82. What is the difference between a while and a do-while loop?
Ans. While: It is entry controlled loop. The test condition is checked before the body of the loop is executed. If the test condition fails in the first run, then the body of the loop is not executed. The keyword used is while.
Do-while: It is an exit controlled loop. The test condition is checked after the body of the loop is executed. If the test condition fails at the first run, then the statements in the body of the loop are executed once. The keywords used do and while.
Q83. How many times will the loop be executed?
a) while(i<=10); (suppose i = 1)
b) for(i=0;i<6;++i)
Ans. a) Infinitely b) 6 times
while (i <= 10) {;}
as i’s value does not satisfy the condition always remains true so continues endlessly.
Q84. The loop counter must be int the data type?
Ans. No, it can even float. It can be incremented by any value, whether it may be an integer value or float value. Any value can increment it.
main() { float x = 5.0; while(x < =5.5) { printf ("Hello"); x = x + 0.1; } }
Q85. Which operators can we use in assignment expression?
Ans. We can use post and pre-increment, decrement operators Eg. ( ++x) and (x++ ). Besides these, we can use assignment operators (+=, -= etc.) and unary operators
Q86. How many variables can we increment or decrement at the same time in the case of for loop? Using the comma operator.
Ans. Two or more Eg: for(i=0,j=9; i<=5; i++,j–)
Q87. What is a Null Statement?
Ans. It is sometimes necessary to cause a delay in a program. Therefore a loop is made to execute many times without producing any result. It is known as the Null Statement. It is written as for statement followed by a semicolon.
Eg. for(i=1000; i>0; i--);
Thus it continues 1000 times without producing any output.
Q88. What is the difference between break and continue?
Ans. A break statement transfers control to the end of the loop, and a continue statement to transfer control to the beginning of the loop.
Q89. What will happen if there is no default in the case of the switch?
Ans. When there is no default case, the program exits from the switch and executes the next instruction that follows the control structure.
Q90. What is the difference between switch and else if ladder?
• switch is better because it is a better way of writing programs than else-if and leads to more structured programming. Thus switch is more simple and manageable. The switch does not allow the use of logical AND(&&) and logical OR (||) operators.
• The block of statements corresponding to a case is not required to be enclosed in curly braces. But else if ladder use of compound statements require braces.
• In the switch statement, a case is usually terminated with a break statement. It is not there in else if ladder.
• switch has an optional default case. It is not there in else if ladder.
• The expression in the switch statement can result in constant type char, int but not of type float and double. It is not in the case of the else-if ladder.
Q91. Why is the use of the goto statement avoided in C?
Ans. The use of goto tends to encourage logic that skips all over the program, but the structured features in C require that the entire program be written in an orderly, sequential manner, so it is avoided.
Q92. What are the basic categories in which control statements can be classified?
1. Decision making statements : Eg: if statement, if-else construct, switch statement.
2. Looping statements: Eg. for the statement, while statement and do-while statement.
3. Jumping statement: Eg. break statement, continue statement, goto statement.
Q93. What is a block?
Ans. A block is a compound statement. A group of statements and declarations surrounded by the opening brace {and closing brace} forms a block.
Q94. What is conditional execution?
Ans. The flow of execution may be transferred from one part of the program to another based on the conditional test’s Output. It is known as conditional execution.
Q95. Write the infinite loops using for loop.
1. for(;;}{ … }
2. for(expressionl ;; expression3) {… }
3. for (;; expression3) {….}
4. for(expressionl;;) {….}
Q96. What is a comma expression?
Ans. A comma expression uses a comma as its operator. The operator allows multiple expressions to be used where a single expression is usually allowed. It is evaluated from left to right when more than one comma operator exists.
Q97. What is called structured goto statements?
Ans. The statements break and continue, known as structured goto statements.
Q98. How is a nested ternary expression evaluated?
Ans. A nested ternary expression is evaluated from right to left. The evaluated value is substituted in ternary expression, and the evaluation continues until all ternary expressions are evaluated.
For example, 3>4?5<6?1:2:10>8?3:4
is evaluated as 3>4? 5<6?1:2:3
and then evaluated as 3>4?1:3
and the result is 3.
Q99. What is a loop inversion?
Ans. If a loop is to be executed for a specified number of times and the counter variable is not used within the loop, the loop may be written as given below using count down instead of count up. This type of looping is known as loop inversion. For example, The loop inversion of the following for loop
for(i=1;i<=10;i++) {...} is written as i = 11; while (--i) {.....}
Q100. How does the comma operator used in the loop differ from nested for loop?
Ans. In the case of the comma operator, the variables replaced by commas are initialized and updated simultaneously. Whereas in nested for loops, the loops are defined one within the other. Therefore, we have different conditions in case of nested for loop put a single condition for loop using a comma operator.
Q101. What is a function?
Ans. A function is a self-contained block of statements that perform some specified task.
Q102. How can functions be classified?
Ans. In two ways
1) Library function Eg. printf(), scanf() etc.
2) User defined functions. Eg. notes(), func1() etc.
Q103. Are library functions part of the language?
Ans. No, we have to include them.
Q104. Expand the following
1. stdio 2. conio 3. stlib 4. ctype
Ans.
stdio.h: Stream (Standard) Input Output
conio.h: Console Input Output
stlib: Standard library
ctype: Character type
Q105. Why do we add (.h) extension when we include library functions?
Ans. The suffix “h” designates a “header” file. The preprocessor statement #include<stdio.h> cause the contents of the file stdio.h to be inserted at the beginning of the compilation process.
Q106. What are the two ways of including header files?
Ans. #include<filename> and #include “filename”.
#include<filename> the angle brackets(< and >) in this case indicates that the compiler searches for the files in the standard INCLUDE directory.
Q106.1 What is the function’s purpose in C?
Ans. :Uses of C function are:
1. In our program, C functions are employed to avoid rewriting the same code over and again.
2. C functions can be invoked as many times as we want from wherever in our program.
3. When we divide a program into functions, we can readily track any portion of our program.
4. C functions provide the concept of reusability, i.e., they divide a large work into smaller ones, making the C program more accessible.
Q107. Can the function be defined in another function?
Ans. No, it cannot be defined, but it can be called from another function.
Q108. Which keyword is used in a function which does not return anything?
Ans. Void.
Q.109 Why should the arguments be in proper order in the function call?
Ans. The arguments (formal arguments) allow the information to be transferred from the calling position of the program, and if they are not in order, it may result in wrong entries.
Q110. If there are no arguments, then it is necessary to specify empty braces in the function call?
Ans. Yes, because this is how it distinguishes a function from an identifier with the same name as the function.
Q111. How should the function be named?
Valid Invalid
int display(int, int); int display point();
int func1();
Ans. The function name should be such that it increases the clarity of function declarations.
Q.112 How many times will it be executed?
main() { .......... main(); .......... }
Ans. Infinitely, as there is no stopping condition. It calls itself again and again.
Q113. What is the use of if statement with recursive function?
Ans. If the statement forces the recursive function to return without a recursive call, making the requirements of stopping condition, otherwise it may fall in an infinite loop.
Q114. If recursive function calls are not executed immediately, then where they are stored?
Ans. They are temporarily stored in a stack. After which, they are popped off.
Q115. What variables are used in a recursive statement: Local or Global?
Ans. They are local. Their values keep on changing, but the name remains the same.
Q116. What value does the main ( ) return?
Ans. main() returns an integer value 1 by default to the operating system.
Q117. Whatis the purpose of the main() function?
Ans. The function main() invokes other functions within it. It is the first function to be called when the program starts execution.
Q118. What is the parameter passing mechanism used in C?
Ans. C uses the call by value method of parameter passing. Any change in the value of the function’s formal parameter is not visible in the calling function.
Q119. Is it possible to have more than one main () function in a C program? Why?
Ans. The function main() can appear only once in a C program because execution commences from the main() function’s first statement. If there is more than one main() function, there will be confusion while commencing the execution. Hence, only one main() function is allowed.
Q120. What is a dummy function?
Ans. A function that performs no action is known as a dummy function. It is a valid function. Dummy functions may be used as a place-holder, which facilitate adding new functions, later on, For example, dummy() {}.
Q120.1 What exactly is recursion in C?
Ans. When a function calls itself, this is referred to as recursion. A recursive function is a function that calls itself.
The recursive function is divided into two stages:
Winding phase: When the recursive code calls itself, and when the condition is reached.
Unwinding phase: When the condition is met, the unwinding phase begins, and control returns to the original call.
Example of Recursion
#include<stdio.h>
int fact(int);
void main()
{
int n,t;
clrscr();
printf(“Enter any Number : “);
scanf(“%d”,& n);
t=fact(n);
printf(“Factorial of %d is : %d”,n,t);
getch();
}
int fact(int a)
{
int p;
if(a==1)
return(1);
else
{
p=a*fact(a-1);
return(p);
}
}
Output: Enter any Number : 5
Factorial of 5 is :120
Q121. What are the advantages of recursion?
• Easier understanding of program logic.
• Writing compact codes.
• Implementing recursively defined data structures.
Q122. Give the features of main().
• It is the starting function.
• It returns an int value to the environment called the program.
• Recursive call is allowed for main () also.
• It is a user-defined function.
• Program execution-ends when the closing brace of the function main() is reached.
Q123. What are the advantages of functions?
1. Debugging is easier.
2. It is easier to understand the logic involved in the program.
3. Testing is easier.
4. Recursive call is possible.
5. Irrelevant details in the user point of view are hidden in functions.
6. Functions help generalize the program.
Q124. What are the storage classes permitted in the function parameters?
Ans. Only register or auto storage class is allowed in the function parameters.
Q125. How are the functions classified based on function call?
Ans. 1. Recursive 2. Non-recursive
Q126. What is the default storage class of variables?
Ans. auto
Q127. Why are automatic variables, also called local variables?
Ans. Since they are visible only locally, i.e. their scope is limited within the function.
Q128. Why are external variable called global variables?
Ans. Since their visibility can be recognized throughout the program.
Q129. When is the storage space allocated to extern variables?
Ans. At the time of definition of the external variables.
Q130. What is the primary purpose served by external variables?
Ans. To transfer information back and forth between functions. In particular, to transfer information back and forth without using arguments.
Q131. What are the inherent dangers of using external variables?
Ans. As the values of external variables are carried over to the other parts of the program, there may be some side effects by which the user may not be aware and may result in subtle errors.
Q132. Which variables are given preference in a function: Local or Global?
Ans. Local
Q133. What is the initial default value in the case of static variables?
Ans. Zero
Q134. Where would be value accessed faster from the register or memory?
Ans. From register.
Q135. Do the variables get stored in CPU registers in register variables?
Ans. As the number of registers is limited, so the variables may or may not get stored depending on the space available. In those cases, they may be treated as automatic variables.
Q136. What type of variables do static variables resemble?
Ans. The static variable’s visibility is the same as that of an automatic variable, and lifetime is the same as that of an external variable.
Q137. Can a global variable have an auto storage specifier?
Ans. No, it will give an error message ‘Incompatible ‘Storage Class’.
Q138. What is a block scope?
Ans. If a variable is recognized only within a particular block, itis said to have block scope. A variable with block scope is a local variable or private variable, or internal variable.
Q139. What is a file scope?
Ans. If a variable is recognized throughout a program written in a single file. It is said to have file scope. The definition of such a variable must be outside all the blocks in the programs. Such a variable is also known as a global variable or public variable. The variable declared by an extern declaration is also a global variable, irrespective of the place of declaration and is known as an external variable.
Q140. What is known as the side effect of a variable?
Ans. A change in the value of a variable in a block has its effect propagated to all places outside the block whenever the same variable is used. This emerging effect is known as a side effect.
Q141. What are the advantages of auto variables?
1. The same auto variable name can be used in different blocks.
2. There is no side effect by changing the values in the block.
3. The memory is economically used.
4. Auto variables have inherent protection because of local scope.
Q142. What are the disadvantages of the external storage class?
1. The storage for an external variable exists even when the variable is not needed.
2. The side effect may produce surprising output.
3. Modification of the program is difficult.
4. Generality of a program is affected.
Q143. What is a forward declaration?
Ans. If a declaration of a variable appears before its definition, it is known as a forward declaration. It is applicable only for the entities having definition and declaration and declaration. The forward declaration is possible with extern variables.
Q144. What is a forward reference?
Ans. Certain entities have definitions and declarations. In such cases, if the declaration appears before its definition and the reference of such a variable is made, it is known as a forward reference. Forward reference is possible with external variables.
Q145. What are arrays?
Ans. Arrays are the collection of homogenous types of data items with the same name and datatype.
E.g. int x [10];
Q146. Can we have an array with 5 members integers and 5 members float?
Ans. No, as they have dissimilar data types, which is contrary to·definition of arrays.
Q147. Why is it better to use symbolic names for size specifications?
Ans. It becomes easier to modify a program by simply making modifications in the value of the symbolic constant.
Q148. How many members will be in x[4]?
Ans. x [n] will represent n elements.
so x [4] gives us n = 4 elements.
Q149. What are the drawbacks of initializing arrays?
1) There is no convenient way to initialize selected elements.
2) There is no shortcut method for initializing a large number of array elements.
Q150. What value will array elements contain if these elements are not initialized?
Ans. Garbage Values
Q151. What is the difference between an array definition and an array declaration?
Ans. Array declaration: In an array declaration, the memory is declared
e.g. int a[10];
Here 10 x 2 = 20 bytes are declared.
Array definition: In array definition, the memory is declared as well as the value is initialized.
eg. int a[5] = { 1 , 2, 3, 4, 5};
In this case, the values are also initialized
a[0] = 1, a[1] = 2, a[2] = 3, a[3] = 4, a[4] = 5
Q152. What will happen in the following statement
main() { int x[20], i; for(i=0; i<80; i++) { x[i]=i; printf("%d\t", x[i]); } }
Ans. No Errors, but there may be unpredictable results.
Q153. How is the entire array passed to the function by value or by reference?
Ans. By Reference. The address of the first element is passed via the function call. The address is assigned to the corresponding formal argument when the function is called.
Q154. How is the allocation of contiguous memory allocation for array helpful?
Ans. By knowing the address of the first element, we can access other elements of the array.
Q155. Why do we not put brackets after the array name in case of a function call?
Eg. avg = funcl (a, x);
(Here x is an array)
Ans. Since it addresses the first element of the array, it can be written simply by array name, i.e. x or by &x[0].
Q156. How can individual members of an array pass to a function?
Ans. Simply by coping each element one by one to the function, i.e. by the call by value.
Q157. What are one-dimensional arrays?
Ans. A linear list of data is called a one-dimensional array.
e.g. int a [5];
i.e. the memory for five elements is declared a[0], a [1] ,………a [4]
Q158. Is the size specifications of an array always an integer?
Ans. Yes, because it represents size which is an integer quantity.
Q159. Can the entire array elements be returned from the function?
Ans. No, since a return statement can return only a single-valued expression. Functions in which array elements are passed do not return the entire array, and void data type declaration is made.
Q160. How can an individual member of a two-dimensional array be referred to?
Ans. Simply by array name followed by the row number and column number enclosed in brackets.
E.g. a[1][2] refers to an element of the second row and 3 columns.
Q161. Why is it essential to specify the size of arrays in advance?
Ans. It helps in allocating that much memory space in advance by the compiler to the array.
Q162. What would be the output of the following?
a) main() { int a[7]={1,5,2,3,4,7,8}; int i,j,m; i = ++a[l]; a[1]++; m = a[i++]; printf ("\n %d%d%d",i, j ,m); }
Ans. a) Now first i = ++a[1] (Pre increment) therefore, i=5+1=6, since, a[1] = 5
Now j = a[1]++ (Post lncrement) =5+1=6
(Since value is printed after incrementation)
Now m = a[i++] So,new value of i= 6 + 1 = 7
m = a[6] = 8
So answer 7 6 8
Q164. What is the difference between a [i] [j] and a [i,j]?
Ans. The variable a[i] [j] represents the jth column and the ith row element. The expression a[i,j] is interpreted as a [j] because the comma is an operator, so the expression i,j is evaluated, and j is returned.
Q165. Is it possible to have a negative index?
Ans. Yes, it is possible to index with a negative value provided data stored in these memory locations. Even though it is illegal to refer to the elements out of array bounds, the compiler will not produce an error because C has no checks on the bounds of an array.
Q166. What are the characteristics of arrays in C?
1. An array holds elements that have the same data type.
2. Array elements are stored in subsequent memory locations.
3. Two-dimensional array elements are stored row by row in subsequent memory locations.
4. Array name represents the address of the starting element.
5. Array size should be mentioned in the declaration. Array size must be the constant expression and not a variable.
Q167. What are the strings?
Ans. Strings can be simply referred to as an array of characters. For, E.g. char a [20] is a string having a length of 20 characters.
Q168. What is the difference between ‘\0’ and ‘0’?
Ans. ‘\0’ is a null character whose ASCII value is 0. It is used with the termination of string, ‘0’ is a character whose ASCII value is 48.
Q169. Is it essential for strings to end with ‘\0’?
Ans. Yes, because it is the only way the functions that work with a string can know where the string ends.
Q170. What will be the size of the character array?
char str [] = “GOD IS GREAT”;
Ans. 13 because 10 characters, 2 blank spaces and one for ‘\0.’
Q171. What difficulty is faced while using scanf for the reading of strings?
Ans. The scanf terminates its input when it finds the first white space, so we don’t get desired output sometimes using it.
Q172. Why don’t we write(&) while using strings in scanf()?
Ans. We don’t write(&) in scanf() while using strings because strings mean an array of characters, and array name itself means the address of the first character.
i.e. char a[10];
scanf (“%s”, a);
a=&a[0];
Q173. Name three-string handling functions available in C?
strlen() = To calculate length of string
strrev() = To reverse a string
strcmp() = To compare two strings
Q174. Under which file are string library functions available?
Ans. In ‘string.h.’
Q175. In two dimensional array of characters, what does the size specifications tell?
Ans. The first size specifications tell about the maximum number of strings, and the second size specifications tell about the maximum length of each string.
Q176. What would be output ?
main() { char name[20] = "HeLko every body"; printf ("%c" ,name[0]); printf("%c",name[2]); }
Ans. Since in the declaration statement, we have declared an array of characters, but in printf, we are printing a single character using %c.
Q177. What are various ways by which strings can be assigned values?
Ans. There are 3 basic ways :
1) During declaration Eg. static char string[]={“……..”};
2) Using strcpy function Eg.strcpy (string,”…….”};
3) Reading a string using scanf function :
Eg: scanf(“%s”, string);
Q178. What is a pointer?
Ans. A pointer is a variable that contains the address of a data item, such as a variable or array element.
Q179. What are the uses of pointers?
1. It is used to pass information back and forth between a function and its reference-point.
2. They provide a way to return multiple data items from a function via function arguments.
3. Reference to other functions can also be made using it.
4. They provide a convenient way to represent multidimensional array by allowing a single multidimensional array to be replaced by a lower-dimensional array of pointers.
Q180. On what does the address of a variable depend?
Ans. The address of the variable depends upon many factors. The computer the program is running on, the size of the operating system and whether other programs are currently in memory. Therefore you may get different outputs on different systems.
Q181. What values can address a variable have?
Ans. The addresses are numbered consecutively, starting from zero. The last address depends upon the memory size.
if 64kb memory than last value 65,535
if 640kb memory than last value 655,359
Q182. Can pointers act upon arithmetic expressions?
Ans. No. only on operands that are pointers.
Q183. What are two ways of accessing a variable?
Ans. Directly by referring to a variable by name and indirectly when we refer to the variable using its address.
Eg. int v, *p;
p = &v;
v = 3 ; Direct Accessing
*p = 3; IndirectAccessing
Q184. Why does only the first memory location of variables gets printed when we use the address of (&) operator with a variable?
Ans. In this case & gives the address of the first byte, the address of the next address can be calculated.
Q185. What is the difference between *p and p?
Ans. Here *p is the pointer variable, and p is an ordinary variable.
Q186. Why are array type variable not preceded by & while passing to a function?
Ans. Since an array name is understood to represent the address, they are not proceeded by an address of (&) operator.
Q187. How can you pass 50 element array to a function?
Ans. By function call, as avg = funcl (&z[50]);
Q188. How is the ith element of array x represented using pointers?
Ans. The x[i] can be represented as *(x + i)
Q189. What are the operations that can be performed on pointer variables?
1. Addition or subtraction of a number from pointers variables. Eg. p1 + 4, p1 – 2,
2 Subtraction of two pointer variables. i.e. p1 – p2
3. Pointer variables can also be compared, provided they print to different elements of the array. Eg. p1 < p2, p1 = = p2, p1 != p2
Q190. What are two ways by which a two-dimensional array can be expressed using pointers?
Ans.1. An array of pointers 2. Pointer to arrays
Q191. What is the use of dynamic memory allocation?
Ans. It helps to reserve space in memory for the variables at the run time, thus saving memory.
Q192. What are the various memory allocation functions available in C?
Ans. malloc(), calloc(), realloc() and free();
Q193. Compare the values returned by & and *.
Ans. The address of the operator & requires an lvalue as its operand, and it returns the actual address of its operand. It does not return an lvalue. The indirection operator * returns an lvalue. It returns the value to which its operand points to.
Q194. Are pointers integers?
Ans. No, pointers are not integers. A pointer is an address. It is merely a positive number and not an integer.
Q195. How are pointer variables initialized?
Ans. Pointers variables are initialized in one of the following two ways.
• Static memory allocation. • Dynamic memory allocation.
Q196. How can pointer variables be incremented and decremented?
Ans. Pointers variables can be incremented or decremented using ++ or –. Pointers operators & and * may be involved while using ++ or –. The operators&,*,++ and — have the same precedence level, and the associativity is from right to left. Care must be taken to evaluate the expression for the intended purpose.
Q197. Differentiate between an array name and a pointer variable.
Ans. A pointer variable is a variable, whereas an array name is a fixed address and is not a variable. A pointer variable must be initialized, but an array name cannot be initialized. An array name is a constant value, ++ and — operators cannot be applied to it.
Q198. Compare arrays and pointers.
Ans. Pointers are used to manipulate data using the addresses. Arrays use subscripted variables to access and manipulate data. Pointers use the * operator to access the data pointed to by them. An array variable can be equivalently written using pointer expressions.
Q199. What does the following declaration mean?
char (*(*f())[])();
Ans. The function returns a pointer to an array of pointers to a function returning character.
Q200. What are the advantages of pointers?
• Pointers can be used as a scalar data type or derived _data type.
• Arrays can be easily accessed using pointers.
• Call by reference is achieved using pointers.
• Complex declarations are possible in pointers.
Q201. What is a null pointer?
Ans. C defines a unique value called null pointer for each pointer type. It is used to compare a pointer to any object or function. The internal representation of the null pointer for different data types may be different.
Q201.1 In C, what is a far pointer?
Ans. A far pointer is a pointer that can access all 16 segments (the entire residence memory) of RAM. A far pointer is a 32-bit pointer that accesses data outside of memory in a certain region.
Q202. When is an explicit cast operator required for a null pointer?
Ans. An explicit cast operator is required for a null pointer in a function call with variable arguments where no prototype is in scope.
Q203. How to cast a null pointer in a function call?
Ans. Only 3 ways are given below:
1. #define NULL((void*) 0) •
It automatically converts 0 to the respective pointer type.
2. #define NULL(type) (type *) 0
It passes the null pointer type needed in the function call.
3. Explicitly typecast the null pointer in the respective function call.
Q204. What does the run-time error message null pointer assignment mean?
Ans. Accessing an uninitialized pointer or an invalid location may cause such errors.
Q205. What happens to pointer p after calling free (p);?
Ans. Strictly speaking, a pointer value that has been freed is invalid. It is of no use, and this pointer value after it has been freed since the value of the pointer remains unchanged because of the call by value parameter passing mechanism. It is implementation-dependent.
Q206. What is the generic pointer?
Ans. A Generic pointer is a pointer to void type to point to a variable of any data type. It offers the advantage of declaring a pointer variable independent of the data type of the variable to which it will point. As the size of the memory location to which it will point is known only at run time so no arithmetic operations can be applied. For example, in the statement void *ptr; ptr is a pointer to void, so it is a generic pointer. One should note that using typecasting. A normal pointer can be converted to a generic pointer and vice versa.
A void pointer cannot be dereferenced directly. The compiler has no information about the type it is pointing to as it contains the address of an unknown data type. Therefore, the void pointer must be converted to a pointer of a particular type. For example, if you want to access the value of a variable a of int type whose address is stored in void pointer p, then you have to typecast as * explicitly ((int *)p).
Q207. What is a dangling pointer?
Ans. A dangling pointer is a pouter that points to a variable that has been deallocated memory and does not exist any more. For example, if a variable goes out of scope, the memory allocated to it will be deallocated, but the pointer will still be pointing to the exact memory location.
Q208. How will you access a member of the Structure, in general?
Ans. By a dot operator. E.g. variable.member
Q209. How are elements stored in arrays of Structure?
Ans. In contiguous memory locations.
Q210. Is the tag used in Structure optional?
Ans. Yes, it may or may not be used.
Q211. What can be the depth of nesting of structures?
Ans. Unlimited, Nesting of Structure can be done an unlimited number of levels.
Q212. Can the tag name and member name be the same?
Ans. Yes, because the tag name is optional, and the member name can be the same as that of the tag in some cases.
Q213. Is it necessary to declare the Structure of the structure member before the Structure?
Ans. Yes, otherwise, it will cause an error.
Q214. Can two different structures declare in the same program have the same-named members?
Ans. Yes, because two different structures are assessed separately using variable member, and therefore member can be identical in different structures.
Q215. What are different ways to access members in a structure?
Ans. (i) Variable member (ii) ptrvar -> member (iii) (*ptrvar).member
if the member is an array, then to access a particular member.
(i) ptrvar ->member[i] (ii) (*ptrvar)->(member + i)
(iii) (*ptrvar).member[i] (iv) (*ptrvar).(member + i)
(v) variable.member[i] (vi) variable.(member + i)
Q216. What would be size of the structure ?
struct date { char name [80]; int day ; int month; float avg; }d;
Ans. 88, since 80 for characters; 2 for the day, 2 for months and 4 for avg.
Q217. Are ++p->a and++ (p -> a ) equivalent?
(Here, p stands for pointer variable and a for a member of Structure?
Ans. Yes, according to precedence rule ->, has the highest precedence so ++p->a is equivalent to ++(p ->a);
Q219. What are two ways of passing Structure to a function?
Pass by Value: Individual members are passed of function
Pass by Reference: Entire Structure is passed by use of pointer variable.
Q220. What are self-referential structures?
Ans. Structures in which atleast one member is a pointer variable pointing to a Structure of the same type is called self-referential structures.
struct list { char item[40]; struct list *next; };
By just altering the pointers, the individual members can be easily added or deleted.
Q221. Is it possible to initialize an array of structures?
Ans. Yes, it is possible to initialize an array of structures.
Q222. What are the features of a structure?
• It permits different data items.
• Array of structures is possible.
• Pointer to a structure is possible.
• Nested Structure is possible.
• Self-referential Structure is possible.
• Structures can be passed as arguments.
• The members can be accessed and manipulated.
• Union can be a member of a structure.
Q223. What are the features of a union?
• Each member of a union shares the same block of memory.
• A union can use a structure as its member.
• Array of unions, the pointer to a union and function with the union as its arguments are possible.
• Nested union may be used.
• Self-referential union is also possible.
Q224. Compare array and Structure.
Ans. Array: An array is a collection of data items of the same data type. It has a declaration only. There is no keyword. An array name represents the address
of the starting element. An array cannot have bit fields.
Structure: A structure is a collection of data items of different data types. It has a declaration and definition. The keyword struct is used. A structure name is known as a tag. It is a shorthand notation of the declaration. A structure may contain bit fields.
Q225. What problem could be faced while opening a file?
Ans. While opening a file in reading mode,
1. File may not be present on the disk at all.
While opening a file in write mode,
1. Disk space is insufficient to open a new file.
2. Disk may be write-protected.
Q226. What do you mean by file pointer?
Ans. A file pointer is a pointer to a particular byte in a file. When we open a file, the file pointer is set to particular bytes, and whenever data is read or written, the pointer moves one position forward.
Q227. What are the different modes in which a file can be opened?
Ans. Different modes in which file can be opened are, read mode (r), write mode (w), append mode (a), read+ (r+), write+ (w+), append+ (a+)
Q228. What do you mean by random or direct access?
Ans. Random or direct access means to reach a particular position in a file without taking care of the current position of the pointer. The function used for random access us fseek.
Q229. What is the difference between a text file and a binary file?
Ans. In the binary mode, the characters and digits are stored by changing them in binary form. In the text mode, the number or characters are stored as a character by character format, i.e. to store 6, it takes only one byte, and 6 is stored as a character.
Q230. Why should the file opened be always closed?
Ans. Closing a file ensures that all outstanding information associated with a file to be flushed out from the buffers and all links to the file broken. It also prevents the misuse of the file.
Q231. Which function is used to access a particular function directly?
Ans. fseek(fptr,offset,mode);
Q232. What are command-line arguments?
Ans. Command-line arguments all the parameters supplied to a program when the program is called. The two arguments which are passed to function main() are
1. argument counter (argc) 2. argument vector (argv).
Q233. What is the difference between the physical filename and logical filename?
Ans. Consider
FILE *fp; fp = fopen("DDD.dat" , "r");
logical filename Physical Filename
Here DDD. dat is a physical filename, and fp is a logical file. The file gets stored in a hard disk using a physical filename, and the pointer fp used in the program to access that particular file is a logical filename.
Q234. What are the arguments possible in main()?
Ans. Two arguments viz.,
1. argument count – representing the number of arguments passed and
2. argument vector – representing the strings passed
are possible as main(int argc, char *argv[]). Here, argc represents argument count and argv represents an argument vector. Any user-defined name can also be used as parameters for main () instead of argc and argv.
Q235. What are the different versions of main()?
1. main()
2. int main (void)
3. int main(int argc, char *argv)
4. int main(int argc, char *argv[])
The arguments argc and argv may also be given any user-defined name.
Q236. List the two types of files in C.
(a) High-level files (stream-oriented files): These files are accessed using library functions.
(b) Low level (system oriented files): These files are accessed system calls.
Q237. What is the stream?
Ans. A stream is a source of data or destination of data associated with a disk or other I/O devices. The source stream provides data to a program, and it is known as an input stream. The destination stream receives the output from the program and is known as an output stream.
Q238. Name the type of I/O streams.
(a) Text stream: It is a sequence of lines of text.
(b) Binary stream: It is a sequence of unprocessed byes.
Q239. What is FILE?
Ans. FILE is a predefined data type. It is defined in stdio.h file.
Q240. We should not read after a write to a file without an intervening call to fflush (), fseek () or rewind()?
Ans. True, after writing to file pointer is pointing to eof so further constraints on reading.
Q241. What is the difference between text and binary mode?
Ans. Text streams are interpreted, with a maximum length of 255 characters. Binary streams are uninterpreted and are treated one byte at a time with no translation of characters.
Q242. What are the advantages of using macro’s?
(i). The compiler generates faster and more compact code for constants than for variables.
(ii) Using variables make programs difficult to understand in large programs.
(iii). There is a danger that the variable’s value(s) be altered somewhere in the program.
Q243. What is the difference between a macro and a function?
Ans. a) 25 b) 1
Note: Hierarchy of operations, one has brackets, and one has no brackets.