Technical interview questions and answers are essential for clearing a C Language Interview because C is the foundation of all modern programming languages. C interviews typically include questions related to pointers, loops, functions, arrays, memory allocation, structures, and file handling. Whether you are preparing for campus placements or software development roles, companies such as TCS, Wipro, Infosys, Cognizant, and Accenture frequently test your C programming basics. This guide includes the most frequently asked C Language interview questions with clear explanations to help freshers and job seekers build strong conceptual understanding. Learning these questions will help you perform confidently in coding rounds, written tests, and technical interviews.
C programmers should advance their skills by learning C++ programming and mastering data structures for algorithm development
1. How do you decide which integer type to use?
Answer: If you might need large values (tens of thousands), use long.Otherwise, if space is very important, use short. Otherwise,use int.
Show Answer
Hide Answer
2. What should the 64-bit type on new, 64-bit machines be?
Answer: There are arguments in favor of long int and long long int,among other options.
Show Answer
Hide Answer
3. What's the best way to declare and define global variables?
Answer: The best arrangement is to place each definition in some relevant .c file, with an external declaration in a header file.
Show Answer
Hide Answer
6. I can't seem to define a linked list node which contains a pointer to itself.
Answer: Structures in C can certainly contain pointers to themselves;the discussion and example in section 6.5 of K&R make this clear. Problems arise if an attempt is made to define (and use) a typedef in the midst of such a declaration; avoid this.
Show Answer
Hide Answer
7. How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters?
Answer: char *(*(*a[N])())();
Using a chain of typedefs, or the cdecl program, makes these declarations easier.
Show Answer
Hide Answer
8. How can I declare a function that returns a pointer to a function of its own type?
Answer: You can't quite do it directly. Use a cast, or wrap a struct around the pointer and return that.
Show Answer
Hide Answer
9. My compiler is complaining about an invalid redeclaration of a function, but I only define it once.
Answer: Calling an undeclared function declares it implicitly as returning int.
Show Answer
Hide Answer
10. What can I safely assume about the initial values of variables which are not explicitly initialized?
Answer: Uninitialized variables with "static" duration start out as 0,as if the programmer had initialized them. Variables with "automatic" duration, and dynamically-allocated memory, start out containing garbage (with the exception of calloc).
Show Answer
Hide Answer
11. Why can't I initialize a local array with a string?
Answer: Perhaps you have a pre-ANSI compiler.
Show Answer
Hide Answer
12. What's wrong with "char *p = malloc(10);" ?
Answer: Function calls are not allowed in initializers for global or static variables.
Show Answer
Hide Answer
13. What is the difference between char a[] = "string"; and char *p = "string"; ?
Answer: The first declares an initialized and modifiable array; the second declares a pointer initialized to a not-necessarily-modifiable constant string.
Show Answer
Hide Answer
14. How do I initialize a pointer to a function?
Answer: Use something like "extern int func(); int (*fp)() = func;"
Show Answer
Hide Answer
15. What's the difference between struct x1 { ... }; and typedef struct { ... } x2; ?
Answer: The first structure is named by a tag, the second by a typedef name.
Show Answer
Hide Answer
16. What's the best way of implementing opaque (abstract) data types in C?
Answer: One good way is to use structure pointers which point to structure types which are not publicly defined.
Show Answer
Hide Answer
17. I came across some code that declared a structure with the last member an array of one element, and then did some tricky allocation to make it act like the array had several elements.Is this legal or portable?
Answer: An official interpretation has deemed that it is not strictly conforming with the C Standard.
Show Answer
Hide Answer
18. Why can't you compare structures?
Answer: There is no single, good way for a compiler to implement structure comparison which is consistent with C's low-level flavor.
Show Answer
Hide Answer
19. How are structure passing and returning implemented?
Answer: If you really need to know, see the unabridged list.
Show Answer
Hide Answer
20. Can I pass constant values to functions which accept structure arguments?
Answer: No. C has no way of generating anonymous structure values.
Show Answer
Hide Answer
21. How can I read/write structures from/to data files?
Answer: It is relatively straightforward to use fread and fwrite.
Show Answer
Hide Answer
23. Why does sizeof report a larger size than I expect for a structure type?
Answer: The alignment of arrays of structures must be preserved.
Show Answer
Hide Answer
24. How can I determine the byte offset of a field within a structure?
Answer: ANSI C defines the offsetof() macro, which should be used if available.
Show Answer
Hide Answer
25. How can I access structure fields by name at run time?
Answer: Build a table of names and offsets, using the offsetof() macro.
Show Answer
Hide Answer
26. I have a program which works correctly, but dumps core after it finishes. Why?
Answer: Check to see if a structure type declaration just before main() is missing its trailing semicolon, causing main() to be declared as returning a structure. See also questions 10.9 and 16.4.
Show Answer
Hide Answer
27. Can I initialize unions?
Answer: ANSI Standard C allows an initializer for the first-named member.
Show Answer
Hide Answer
28. What is the difference between an enumeration and a set of preprocessor #defines?
Answer: At the present time, there is little difference. The C Standard states that enumerations are compatible with integral types.
Show Answer
Hide Answer
30. Why doesn't the code "a[i] = i++;" work?
Answer: The variable i is both referenced and modified in the same expression.
Show Answer
Hide Answer
31. Under my compiler, the code "int i = 7;printf("%d\n", i++ * i++);" prints 49. Regardless of the order
of evaluation, shouldn't it print 56?
Answer: The operations implied by the postincrement and postdecrement operators ++ and -- are performed at some time after the operand's former values are yielded and before the end of the expression, but not necessarily immediately after, or before other parts of the expression are evaluated.
Show Answer
Hide Answer
32. How could the code "int i = 3; i = i++;" ever give 7?
Answer: Undefined behavior means *anything* can happen.
Show Answer
Hide Answer
33. Don't precedence and parentheses dictate order of evaluation?
Answer: Operator precedence and explicit parentheses impose only a partial ordering on the evaluation of an expression, which does not generally include the order of side effects.
Show Answer
Hide Answer
34. But what about the && and || operators?
Answer: There is a special exception for those operators: left-to-right evaluation is guaranteed.
Show Answer
Hide Answer
35. What's a "sequence point"?
Answer: The point (at the end of a full expression, or at the ||, &&,?:, or comma operators, or just before a function call) at which all side effects are guaranteed to be complete.
Show Answer
Hide Answer
36. So given a[i] = i++; we don't know which cell of a[] gets written to, but i does get incremented by one, right?
Answer: *No.* Once an expression or program becomes undefined, *all* aspects of it become undefined.
Show Answer
Hide Answer
37. If I'm not using the value of the expression, should I use i++ or ++i to increment a variable?
Answer: Since the two forms differ only in the value yielded, they are entirely equivalent when only their side effect is needed.
Show Answer
Hide Answer
38. Why doesn't the code "int a = 1000, b = 1000; long int c = a * b;" work?
Answer: You must manually cast one of the operands to (long).
Show Answer
Hide Answer
40. What's wrong with "char *p; *p = malloc(10);"?
Answer: The pointer you declared is p, not *p.
Show Answer
Hide Answer
41. Does *p++ increment p, or what it points to?
Answer: *p++ increments p. To increment the value pointed to by p, use (*p)++ .
Show Answer
Hide Answer
42. I have a function which accepts, and is supposed to initialize,a pointer, but the pointer in the caller remains unchanged.
Answer: The called function probably altered only the passed copy of the pointer.
Show Answer
Hide Answer
43. I have a function which accepts a pointer to an int. How can I pass a constant like 5 to it?
Answer: You will have to declare a temporary variable.
Show Answer
Hide Answer
44. Does C even have "pass by reference"?
Answer: Not really, though it can be simulated.
Show Answer
Hide Answer
45. I've seen different methods used for calling functions via pointers
Answer: The extra parentheses and explicit * are now officially optional, although some older implementations require them.
Show Answer
Hide Answer
46. What is this infamous null pointer, anyway?
Answer: For each pointer type, there is a special value -- the "null pointer" -- which is distinguishable from all other pointer values and which is not the address of any object or function.
Show Answer
Hide Answer
47. How do I get a null pointer in my programs?
Answer: A constant 0 in a pointer context is converted into a null pointer at compile time. A "pointer context" is an initialization, assignment, or comparison with one side a variable or expression of pointer type, and (in ANSI standard C) a function argument which has a prototype in scope declaring a certain parameter as being of pointer type. In other contexts (function arguments without prototypes, or in the variable part of variadic function calls) a constant 0 with an appropriate explicit cast
Show Answer
Hide Answer
48. Is the abbreviated pointer comparison "if(p)" to test for non-null pointers valid?
Answer: Yes. The construction "if(p)" works, regardless of the internal representation of null pointers, because the compiler essentially rewrites it as "if(p != 0)" and goes on to convert 0 into the correct null pointer.
Show Answer
Hide Answer
49. What is NULL and how is it #defined?
Answer: NULL is simply a preprocessor macro, #defined as 0 (or ((void *)0)), which is used (as a stylistic convention, in preference to unadorned 0's) to generate null pointers.
Show Answer
Hide Answer
50. How should NULL be defined on a machine which uses a nonzero bit pattern as the internal representation of a null pointer?
Answer: The same as on any other machine: as 0 (or ((void *)0)). (The compiler makes the translation, upon seeing a 0, not the preprocessor.
Show Answer
Hide Answer
51. What does static variable mean?
Answer: Static variables are the variables which retain their values between the function calls. They are initialized only once their scope is within the function in which they are defined.
Show Answer
Hide Answer
52. What is a pointer?
Answer: Pointers are variables which stores the address of another variable. That variable may be a scalar (including another pointer), or an aggregate (array or structure). The pointed-to object may be part of a larger object, such as a field of a structure or an element in an array.
Show Answer
Hide Answer
53. What is a structure?
Answer: Structure constitutes a super data type which represents several different data types in a single unit. A structure can be initialized if it is static or global.
Show Answer
Hide Answer
54. What is a union?
Answer: Union is a collection of heterogeneous data type but it uses efficient memory utilization technique by allocating enough memory to hold the largest member. Here a single area of memory contains values of different types at different time. A union can never be initialized.
Show Answer
Hide Answer
55. What are the differences between structures and union?
Answer: A structure variable contains each of the named members, and its size is large enough to hold all the members. Structure elements are of same size.
A union contains one of the named members at a given time and is large enough to hold the largest member. Union element can be of different sizes.
Show Answer
Hide Answer
56. What are the differences between structures and arrays?
Answer: tructure is a collection of heterogeneous data type but array is a collection of homogeneous data types
Show Answer
Hide Answer
57. In header files whether functions are declared or defined?
Answer: Functions are declared within header file. That is function prototypes exist in a header file,not function bodies. They are defined in library (lib).
Show Answer
Hide Answer
58. What are the differences between malloc () and calloc ()?
Answer: Malloc Calloc 1-Malloc takes one argument Malloc(a);where a number of bytes 2-memory allocated contains garbage values
1-Calloc takes two arguments Calloc(b,c) where b no of object and c size of object
2-It initializes the contains of block of memory to zerosMalloc takes one argument, memory allocated contains garbage values.
It allocates contiguous memory locations. Calloc takes two arguments, memory allocated contains all zeros, and the memory allocated is not contiguous.
Show Answer
Hide Answer
59. What are macros? What are its advantages and disadvantages?
Answer: Macros are abbreviations for lengthy and frequently used statements. When a macro is called the entire code is substituted by a single line though the macro definition is of several lines.
The advantage of macro is that it reduces the time taken for control transfer as in case of
function.
The disadvantage of it is here the entire code is substituted so the program becomes
lengthy if a macro is called several times.
Show Answer
Hide Answer
60. Difference between pass by reference and pass by value?
Answer: Pass by reference passes a pointer to the value. This allows the callee to modify the variable directly.Pass by value gives a copy of the value to the callee. This allows the callee to modify the value without modifying the variable. (In other words, the callee simply cannot modify the variable, since it lacks a reference to it.)
Show Answer
Hide Answer
61. What is static identifier?
Answer: A file-scope variable that is declared static is visible only to functions within that file. A
function-scope or block-scope variable that is declared as static is visible only within that scope. Furthermore, static variables only have a single instance. In the case of function- or block-scope variables, this means that the variable is not “automatic” and thus retains its value across function invocations.
Show Answer
Hide Answer
62. Where is the auto variables stored?
Answer: Auto variables can be stored anywhere, so long as recursion works. Practically, theyre stored on
the stack. It is not necessary that always a stack exist. You could theoretically allocate function invocation records from the heap.
Show Answer
Hide Answer
63. Where does global, static, and local, register variables, free memory and C Program instructions get stored?
Answer: Global: Wherever the linker puts them. Typically the “BSS segment” on many platforms.
Static: Again, wherever the linker puts them. Often, theyre intermixed with the globals. The only difference between globals and statics is whether the linker will resolve the symbols across compilation units.Local: Typically on the stack, unless the variable gets register allocated and never spills.Register: Nowadays, these are equivalent to “Local” variables. They live on the stack unless they get register-
Show Answer
Hide Answer
64. Difference between arrays and linked list?
Answer: An array is a repeated pattern of variables in contiguous storage. A linked list is a set of
structures scattered through memory, held together by pointers in each element that point to the next element. With an array, we can (on most architectures) move from one element to the next by adding a fixed constant to the integer value of the pointer. With a linked list, there is a “next” pointer in each structure which says what element comes next.
Show Answer
Hide Answer
65. What are enumerations?
Answer: They are a list of named integer-valued constants. Example:enum color { black , orange=4,
yellow, green, blue, violet };This declaration defines the symbols “black”, “orange”, “yellow”, etc. to have the values “1,” “4,” “5,” … etc. The difference between an enumeration and a macro is that the enum actually declares a type, and therefore can be type checked.
Show Answer
Hide Answer
66. What are register variables? What are the advantages of using register variables?
Answer: If a variable is declared with a register storage class,it is known as register variable.The
register variable is stored in the cpu register instead of main memory.Frequently used variables
are declared as register variable as Its access time is faster.
Show Answer
Hide Answer
67. What is the use of typedef?
Answer: The typedef help in easier modification when the programs are ported to another machine.
A descriptive new name given to the existing data type may be easier to understand the code.
Show Answer
Hide Answer
68. Can we specify variable field width in a scanf() format string? If possible how?
Answer: All field widths are variable with scanf(). You can specify a maximum field width for a given
field by placing an integer value between the ‘% and the field type specifier. (e.g. %64s). Such a specifier will still accept a narrower field width.
The one exception is %#c (where # is an integer). This reads EXACTLY # characters, and it is the
only way to specify a fixed field width with scanf().
Show Answer
Hide Answer
69. Out of fgets() and gets() which function is safe to use and why?
Answer: fgets() is safer than gets(), because we can specify a maximum input length. Neither one is completely safe, because the compiler cant prove that programmer wont overflow the buffer he pass to fgets ().
Show Answer
Hide Answer
70. Difference between strdup and strcpy?
Answer: Both copy a string. strcpy wants a buffer to copy into. strdup allocates a buffer using malloc().
Unlike strcpy(), strdup() is not specified by ANSI .
Show Answer
Hide Answer
71. What is recursion?
Answer: A recursion function is one which calls itself either directly or indirectly it must halt at a definite point to avoid infinite recursion.
Show Answer
Hide Answer
72. Differentiate between for loop and a while loop? What are it uses?
Answer: For executing a set of statements fixed number of times we use for loop while when the number of
iterations to be performed is not known in advance we use while loop.
Show Answer
Hide Answer
73. What is storage class? What are the different storage classes in C?
Answer: Storage class is an attribute that changes the behavior of a variable. It controls the lifetime, scope and linkage. The storage classes in c are auto, register, and extern, static, typedef.
Show Answer
Hide Answer
74. What the advantages of using Unions?
Answer: When the C compiler is allocating memory for unions it will always reserve enough room for the
largest member.
Show Answer
Hide Answer
75. What is the difference between Strings and Arrays?
Answer: String is a sequence of characters ending with NULL .it can be treated as a one dimensional array
of characters terminated by a NULL character.
Show Answer
Hide Answer
76. What is a far pointer? Where we use it?
Answer: In large data model (compact, large, huge) the address B0008000 is acceptable because in these
model all pointers to data are 32bits long. If we use small data model(tiny, small, medium) the above address wont work since in these model each pointer is 16bits long. If we are working in a small data model and want to access the address B0008000 then we use far pointer. Far pointer is always treated as a 32bit pointer and contains a segment address and offset address both of 16bits each. Thus the
Show Answer
Hide Answer
77. What is a huge pointer?
Answer: Huge pointer is 32bit long containing segment address and offset address. Huge pointers are
normalized pointers so for any given memory address there is only one possible huge address segment: offset pair. Huge pointer arithmetic is doe with calls to special subroutines so its arithmetic slower than any other pointers.
Show Answer
Hide Answer
78. What is a normalized pointer, how do we normalize a pointer?
Answer: It is a 32bit pointer, which has as much of its value in the segment register as possible. Since
a segment can start every 16bytes so the offset will have a value from 0 to F. for normalization convert the address into 20bit address then use the 16bit for segment address and 4bit for the offset address. Given a pointer 500D: 9407,we convert it to a 20bitabsolute address 549D7,Which then normalized to 549D:0007.
Show Answer
Hide Answer
79. What is near pointer?
Answer: A near pointer is 16 bits long. It uses the current content of the CS (code segment) register (if
the pointer is pointing to code) or current contents of DS (data segment) register (if the pointer is pointing to data) for the segment part, the offset part is stored in a 16 bit near pointer. Using near pointer limits the data/code to 64kb segment.
Show Answer
Hide Answer
80. In C, why is the void pointer useful? When would you use it?
Answer: The void pointer is useful because it is a generic pointer that any pointer can be cast into and
back again without loss of information.
Show Answer
Hide Answer
81. What is a NULL Pointer? Whether it is same as an uninitialized pointer?
Answer: Null pointer is a pointer which points to nothing but uninitialized pointer may point to anywhere.
Show Answer
Hide Answer
82. Are pointers integer?
Answer: No, pointers are not integers. A pointer is an address. It is a positive number.
Show Answer
Hide Answer
83. What does the error ‘Null Pointer Assignment means and what causes this error?
Answer: As null pointer points to nothing so accessing a uninitialized pointer or invalid location may cause an error.
Show Answer
Hide Answer
84. 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).
Show Answer
Hide Answer
85. Are the expressions arr and &arr same for an array of integers?
Answer: Yes for array of integers they are same.
Show Answer
Hide Answer
86. IMP>How pointer variables are initialized?
Answer: Pointer variables are initialized by one of the following ways.
I. Static memory allocation
II. Dynamic memory allocation
Show Answer
Hide Answer
87. What is static memory allocation?
Answer: Compiler allocates memory space for a declared variable. By using the address of operator, the
reserved address is obtained and this address is assigned to a pointer variable. This way of assigning pointer value to a pointer variable at compilation time is known as static memory allocation.
Show Answer
Hide Answer
88. What is dynamic memory allocation?
Answer: A dynamic memory allocation uses functions such as malloc() or calloc() to get memory dynamically. If these functions are used to get memory dynamically and the values returned by these function are assigned to pointer variables, such a way of allocating memory at run time is known as dynamic memory allocation.
Show Answer
Hide Answer
89. What is the purpose of realloc?
Answer: It increases or decreases the size of dynamically allocated array. The function realloc (ptr,n) uses two arguments. The first argument ptr is a pointer to a block of memory for which the size is to be altered. The second argument specifies the new size. The size may be increased or decreased. If sufficient space is not available to the old region the function may create a new region.
Show Answer
Hide Answer
90. What is an array of pointers?
Answer: if the elements of an array are addresses, such an array is called an array of pointers.
Show Answer
Hide Answer
91. Difference between linker and linkage?
Answer: Linker converts an object code into an executable code by linking together the necessary built in
functions. The form and place of declaration where the variable is declared in a program determine the linkage of variable.
Show Answer
Hide Answer
92. Is it possible to have negative index in an array?
Answer: Yes it is possible to index with negative value provided there are data stored in this location. Even if it is illegal to refer to the elements that are out of array bounds, the compiler will not produce error because C has no check on the bounds of an array.
Show Answer
Hide Answer
93. Why is it necessary to give the size of an array in an array declaration?
Answer: When an array is declared, the compiler allocates a base address and reserves enough space in
memory for all the elements of the array. The size is required to allocate the required space and hence size must be mentioned.
Show Answer
Hide Answer
94. What modular programming?
Answer: If a program is large, it is subdivided into a number of smaller programs that are called modules or subprograms. If a complex problem is solved using more modules, this approach is known as modular programming.
Show Answer
Hide Answer
95. What is a function?
Answer: A large program is subdivided into a number of smaller programs or subprograms. Each subprogram
Show Answer
Hide Answer
96. What is an argument?
Answer: An argument is an entity used to pass data from the calling to a called function.
Show Answer
Hide Answer
97. What are built in functions?
Answer: The functions that are predefined and supplied along with the compiler are known as built-in functions. They are also known as library functions.
Show Answer
Hide Answer
98. Difference between formal argument and actual argument?
Answer: Formal arguments are the arguments available in the function definition. They are preceded by
their own data type. Actual arguments are available in the function call. These arguments are given
as constants or variables or expressions to pass the values to the function.
Show Answer
Hide Answer
99. Is it possible to have more than one main() function in a C program ?
Answer: The function main() can appear only once. The program execution starts from main.
Show Answer
Hide Answer
100. 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.
Show Answer
Hide Answer
101. How are Structure passing and returning implemented by the complier?
Answer: When structures are passed as argument to functions, the entire structure is typically pushed on
the stack. To avoid this overhead many programmer often prefer to pass pointers to structure instead of actual structures. Structures are often returned from functions in a location pointed to by an extra, compiler-supported ‘hidden argument to the function.
Show Answer
Hide Answer
102. what is the similarity between a Structure, Union and enumeration?
Answer: All of them let the programmer to define new data type.
Show Answer
Hide Answer
103. Can a Structure contain a Pointer to itself?
Answer: Yes such structures are called self-referential structures.
Show Answer
Hide Answer
104. How can we read/write Structures from/to data files?
Answer: To write out a structure we can use fwrite() as Fwrite( &e, sizeof(e),1,fp);Where e is a structure
variable. A corresponding fread() invocation can read the structure back from file. calling fwrite() it writes out sizeof(e) bytes from the address &e. Data files written as memory images with fwrite(),however ,will not be portable, particularly if they contain floating point fields or Pointers. This is because memory layout of structures is machine and compiler
dependent. Therefore, structures w
Show Answer
Hide Answer
105. Write a program which employs Recursion?
Answer: int fact(int n) { return n > 1 ? n * fact(n 1) : 1; }
Show Answer
Hide Answer
106. Write a program which uses Command Line Arguments?
Answer: #include
void main(int argc,char *argv[])
{
int i;
clrscr();
for(i=0;i
printf(“\n%d”,argv[i]);
}
Show Answer
Hide Answer
107. What do the ‘c and ‘v in argc and argv stand for?
Answer: The c in argc(argument count) stands for the number of command line argument the program is
invoked with and v in argv(argument vector) is a pointer to an array of character string that contain the arguments.
Show Answer
Hide Answer
108. what are C tokens?
Answer: There are six classes of tokens: identifier, keywords, constants, string literals, operators and other separators.
Show Answer
Hide Answer
109. What are C identifiers?
Answer: These are names given to various programming element such as variables, function, arrays.It is a combination of letter, digit and underscore.It should begin with letter. Backspace is not allowed.
Show Answer
Hide Answer
110. What is preincrement and post increment?
Answer: ++n (pre increment) increments n before its value is used in an assignment operation or any
expression containing it. n++ (post increment) does increment after the value of n is used.
Show Answer
Hide Answer
111. What is the maximum combined length of command line arguments including the space between adjacent arguments?
Answer: It depends on the operating system.
Show Answer
Hide Answer
112. What is the difference between the functions memmove() and memcpy()?
Answer: The arguments of memmove() can overlap in memory. The arguments of memcpy() cannot.
Show Answer
Hide Answer
113. What is a file?
Answer: A file is a region of storage in hard disks or in auxiliary storage devices.It contains bytes of
information .It is not a data type.
Show Answer
Hide Answer
114. what are the types of file?
Answer: Files are of two types
1-high level files (stream oriented files) :These files are accessed using library functions
2-low level files(system oriented files) :These files are accessed using system calls
Show Answer
Hide Answer
115. what is a stream?
Answer: A stream is a source of data or destination of data that may be associated with a disk or other
I/O device. The source stream provides data to a program and it is known as input stream. The destination stream eceives the output from the program and is known as output stream.
Show Answer
Hide Answer
116. What is meant by file opening?
Answer: The action of connecting a program to a file is called opening of a file. This requires creating
an I/O stream before reading or writing the data.
Show Answer
Hide Answer
117. What is FILE?
Answer: FILE is a predefined data type. It is defined in stdio.h file.
Show Answer
Hide Answer
118. What is a file pointer?
Answer: The pointer to a FILE data type is called as a stream pointer or a file pointer. A file pointer points to the block of information of the stream that had just been opened.
Show Answer
Hide Answer
119. How is a file closed ?
Answer: A file is closed using fclose() function
Eg. fclose(fp);
Where fp is a file pointer.
Show Answer
Hide Answer
120. Are the expressions *ptr ++ and ++ *ptr same?
Answer: No,*ptr ++ increments pointer and not the value pointed by it. Whereas ++ *ptr
increments the value being pointed to by ptr.
Show Answer
Hide Answer
121. What would be the equivalent pointer expression foe referring the same element as
a[p][q][r][s] ?
Answer: *( * ( * ( * (a+p) + q ) + r ) + s)
Show Answer
Hide Answer
122. Are the variables argc and argv are always local to main?
Answer: Yes they are local to main.
Show Answer
Hide Answer
123. Can main () be called recursively?
Answer: Yes any function including main () can be called recursively.
Show Answer
Hide Answer
124. IMP>Can we initialize unions?
Answer: ANSI Standard C allows an initializer for the first member of a union. There is no standard way
of initializing any other member
Show Answer
Hide Answer
125. whats the difference between these two declarations?
Answer: (nor, under a pre-ANSI compiler, is there generally any way of
initializing a union at all).
Show Answer
Hide Answer
126. Why doesnt this code: a[i] = i++; work?
Answer: The subexpression i++ causes a side effect.it modifies is value.which leads to undefined
behavior since i is also referenced elsewhere in the same expression.
Show Answer
Hide Answer
127. WHy doesnt struct x { … };
x thestruct;
work?
Answer: C is not C++. Typedef names are not automatically generated for structure tags.
Show Answer
Hide Answer
128. Why cant we compare structures?
Answer: There is no single, good way for a compiler to implement structure comparison which is consistent with Cs low-level flavor. A simple byte-by-byte comparison could founder on random bits present in unused “holes” in the structure (such padding is used to keep the alignment of later fields correct). A field-by-field comparison might require unacceptable amounts of repetitive code for large structures.
Show Answer
Hide Answer
129. Can we use any name in place of argv and argc as command line arguments ?
Answer: yes we can use any user defined name in place of argc and argv;
Show Answer
Hide Answer
130. What is the difference between an Interface and an Abstract class?
Answer: An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation. An abstract class is a class which may have the usual flavors of class members (private, protected, etc.), but has some abstract methods.
Show Answer
Hide Answer