Você está na página 1de 103

www.hirist.

com

hirist
.com

TOPC 100
INTERVIEW QUESTIONS & ANSWERS

hirist
.com

QUESTION 1

QUESTION
Who invented C Language?

ANSWER
Dennis Ritchie in 1972 developed a new language by inheriting the features of both BCPL and B and adding
additional features. He named the language as just C

For the hottest C jobs, please visit www.hirist.com

hirist
.com

QUESTION 2

QUESTION
What are the features of C Langauges?

ANSWER
In C one can write programs like that of high level languages as in COBOL, BASIC, FORTRAN etc. as well as it
permits very close interaction with the inner workings of the computer.
It is a general purpose programming language. It is usually called system programming language but equally
suited to writing a variety of applications.
It supports various data types
It follows the programming style based on fundamental control flow constructions for structured programming
Functions may be predefined or user defined and they may return values of basic types, structures, unions or
pointers

For the hottest C jobs, please visit www.hirist.com

hirist
.com

QUESTION 3

QUESTION
What are the advantages of c language?

ANSWER
Easy to write

Ability to write TSR programs

Rich set of operators and functions that are builtin

Ability to create .COM files

Support for bitwise operation

Ability to create library files (.LIB)

Flexible use of pointers

Ability to write interface programs

Direct control over the hardware

Incorporating assembly language in C program

Ability to access BIOS/DOS routines


Interacting using Interrupts

For the hottest C jobs, please visit www.hirist.com

hirist
.com

QUESTION 4

QUESTION
What is a header file?

ANSWER
Header files provide the definitions and declarations for the library functions. Thus, each header file contains the
library functions along with the necessary definitions and declarations. For example, stdio.h, math.h, stdlib.h,
string.h etc.

For the hottest C jobs, please visit www.hirist.com

hirist
.com

QUESTION 5

QUESTION
List the different types of C tokens?

ANSWER
Constants
Identifiers
Keywords
Operators
Special symbols
Strings

For the hottest C jobs, please visit www.hirist.com

hirist
.com

QUESTION 6

QUESTION
What is a constant? What are the different types of constants?

ANSWER
A constant is a value that does not change during the program execution. A constant used in C does not occupy
memory. There are five types of constants. They are:
Integer constants
Floating point constants
Character constants
String literals
Enumeration constants

For the hottest C jobs, please visit www.hirist.com

hirist
.com

QUESTION 7

QUESTION
What are the different types of c instructions?

ANSWER
There are basically three types of instructions in C are :
Type Declaration Instruction
Arithmetic Instruction
Control Instruction

For the hottest C jobs, please visit www.hirist.com

hirist
.com

QUESTION 8

QUESTION
Why C is called a middle level language?

ANSWER
C combines the features of both Assembly Level Languages (Low Level Languages) and Higher Level Languages.
For this reason, C is referred to as a Middle Level Language. The feature of ALLs is that of enabling us to develop
system level programs and the features of HLLs are those of higher degree of readability and machine
independence.

For the hottest C jobs, please visit www.hirist.com

hirist
.com

QUESTION 9

QUESTION
What is the purpose of main() function?

ANSWER
The function main() invokes other functions within it. It is the first function to be called when the program starts
execution.
It is the starting function.
It returns an int value to the environment that called the program.
Recursive call is allowed for main( ) also.
It is a user-defined function.

For the hottest C jobs, please visit www.hirist.com

10

hirist
.com

QUESTION 10

QUESTION
What is meant by type specifiers?

ANSWER
Type specifiers decide the amount of memory space occupied by a variable. In the ease of integral types; it also
explicitly states the range of values that the object can hold.

For the hottest C jobs, please visit www.hirist.com

11

hirist
.com

QUESTION 11

QUESTION
What is the difference between single charater constant and string constant?

ANSWER
A single character constant consists of only one character and it is enclosed within a pair of single quotes.
A string constant consists of one or more characters and it is enclosed within a pair of double quotes.

For the hottest C jobs, please visit www.hirist.com

12

hirist
.com

QUESTION 12

QUESTION
What is a loop?

ANSWER
A loop is a process to do a job repeatedly with possibly different data each time. The statements executed each time
constitute the loop body, and each pass is called iteration. A condition must be present to terminate the loop.

For the hottest C jobs, please visit www.hirist.com

13

hirist
.com

QUESTION 13

QUESTION
What are the types of data types and explain?

ANSWER
There are five basic Data types in C. These are :
void: means nothing i.e. no data involvement in an action
char: to work with all types of characters used in computer operations
int: to work with an integer type of data in any computational work
float: to work with the real type of data or scientific numbers in the exponential form
double: to work with double precision of numbers when the approximation is very crucial.

For the hottest C jobs, please visit www.hirist.com

14

hirist
.com

QUESTION 14

QUESTION
What is the general form of a C program?

ANSWER
A C program begins with the preprocessor directives, in which the programmer would specify which header file and
what constants (if any) to be used. This is followed by the main function heading. Within the main function lies the
variable declaration and program statement.

For the hottest C jobs, please visit www.hirist.com

15

hirist
.com

QUESTION 15

QUESTION
What is the difference between Call by Value and Call by Reference?

ANSWER
When using Call by Value, you are sending the value of a variable as parameter to a function, whereas Call by
Reference sends the address of the variable. Also, under Call by Value, the value in the parameter is not affected
by whatever operation that takes place, while in the case of Call by Reference, values can be affected by the
process within the function.

For the hottest C jobs, please visit www.hirist.com

16

hirist
.com

QUESTION 16

QUESTION
What is a stack?

ANSWER
A stack is one form of a data structure. Data is stored in stacks using the FILO (First In Last Out) approach. At any
particular instance, only the top of the stack is accessible, which means that in order to retrieve data that is stored
inside the stack, those on the upper part should be extracted first. Storing data in a stack is also referred to as a
PUSH, while data retrieval is referred to as a POP.

For the hottest C jobs, please visit www.hirist.com

17

hirist
.com

QUESTION 17

QUESTION
What is the use of a \0 character?

ANSWER
It is referred to as a terminating null character, and is used primarily to show the end of a string value.

For the hottest C jobs, please visit www.hirist.com

18

hirist
.com

QUESTION 18

QUESTION
What is the difference between the = symbol and == symbol?

ANSWER
The = symbol is often used in mathematical operations. It is used to assign a value to a given variable. On the other
hand, the = = symbol, also known as equal to or equivalent to, is a relational operator that is used to compare
two values

For the hottest C jobs, please visit www.hirist.com

19

hirist
.com

QUESTION 19

QUESTION
What is the modulus operator?

ANSWER
The modulus operator outputs the remainder of a division. It makes use of the percentage (%) symbol. For example:
10 % 3 = 1, meaning when you divide 10 by 3, the remainder is 1.

For the hottest C jobs, please visit www.hirist.com

20

hirist
.com

QUESTION 20

QUESTION
Which of the following operators is incorrect and why? ( >=, <=, <>, ==)

ANSWER
<> is incorrect. While this operator is correctly interpreted as not equal to in writing conditional statements, it is not
the proper operator to be used in C programming. Instead, the operator != must be used to indicate not equal
to condition.

For the hottest C jobs, please visit www.hirist.com

21

hirist
.com

QUESTION 21

QUESTION
What is syntax error?

ANSWER
Syntax errors are associated with mistakes in the use of a programming language. It maybe a command that was
misspelled or a command that must was entered in lowercase mode but was instead entered with an upper case
character. A misplaced symbol, or lack of symbol, somewhere within a line of code can also lead to syntax error.

For the hottest C jobs, please visit www.hirist.com

22

hirist
.com

QUESTION 22

QUESTION
Can I use int data type to store the value 32768? Why?

ANSWER
No. int data type is capable of storing values from -32768 to 32767. To store 32768, you can use long int instead.
You can also use unsigned int, assuming you dont intend to store negative values.

For the hottest C jobs, please visit www.hirist.com

23

hirist
.com

QUESTION 23

QUESTION
When is the void keyword used in a function?

ANSWER
When declaring functions, you will decide whether that function would be returning a value or not. If that function will
not return a value, such as when the purpose of a function is to display some outputs on the screen, then void is
to be placed at the leftmost part of the function header. When a return value is expected after the function
execution, the data type of the return value is placed instead of void.

For the hottest C jobs, please visit www.hirist.com

24

hirist
.com

QUESTION 24

QUESTION
What is the significance of an algorithm to C programming?

ANSWER
Before a program can be written, an algorithm has to be created first. An algorithm provides a step by step
procedure on how a solution can be derived. It also acts as a blueprint on how a program will start and end,
including what process and computations are involved.

For the hottest C jobs, please visit www.hirist.com

25

hirist
.com

QUESTION 25

QUESTION
How do you generate random numbers in C?

ANSWER
Random numbers are generated in C using the rand() command. For example: anyNum = rand() will generate any
integer number beginning from 0, assuming that anyNum is a variable of type integer.

For the hottest C jobs, please visit www.hirist.com

26

hirist
.com

QUESTION 26

QUESTION
What is debugging?

ANSWER
Debugging is the process of identifying errors within a program. During program compilation, errors that are found
will stop the program from executing completely. At this state, the programmer would look into the possible
portions where the error occurred. Debugging ensures the removal of errors, and plays an important role in
ensuring that the expected program output is met.

For the hottest C jobs, please visit www.hirist.com

27

hirist
.com

QUESTION 27

QUESTION
What does the && operator do in a program code?

ANSWER
The && is also referred to as AND operator. When using this operator, all conditions specified must be TRUE before
the next action can be performed. If you have 10 conditions and all but 1 fails to evaluate as TRUE, the entire
condition statement is already evaluated as FALSE.

For the hottest C jobs, please visit www.hirist.com

28

hirist
.com

QUESTION 28

QUESTION
What is || operator and how does it function in a program?

ANSWER
The || is also known as the OR operator in C programming. When using || to evaluate logical conditions, any
condition that evaluates to TRUE will render the entire condition statement as TRUE.

For the hottest C jobs, please visit www.hirist.com

29

hirist
.com

QUESTION 29

QUESTION
What will be the outcome of the following conditional statement if the value of
variable s is 10? s >=10 && s < 25 && s!=12
ANSWER
The outcome will be TRUE. Since the value of s is 10, s >= 10 evaluates to TRUE because s is not greater than 10
but is still equal to 10. s< 25 is also TRUE since 10 is less then 25. Just the same, s!=12, which means s is not
equal to 12, evaluates to TRUE. The && is the AND operator, and follows the rule that if all individual conditions
are TRUE, the entire statement is TRUE.

For the hottest C jobs, please visit www.hirist.com

30

hirist
.com

QUESTION 30

QUESTION
What is FIFO?

ANSWER
In C programming, there is a data structure known as queue. In this structure, data is stored and accessed using
FIFO format, or First-In-First-Out. A queue represents a line wherein the first data that was stored will be the first
one that is accessible as well.

For the hottest C jobs, please visit www.hirist.com

31

hirist
.com

QUESTION 31

QUESTION
In C language, the variables NAME, name, and Name are all the same. TRUE or
FALSE?
ANSWER
FALSE. C language is a case sensitive language. Therefore, NAME, name and Name are three uniquely different
variables.

For the hottest C jobs, please visit www.hirist.com

32

hirist
.com

QUESTION 32

QUESTION
When is a switch statement preferable over an if statement?

ANSWER
The switch statement is best used when dealing with selections based on a single variable or expression. However,
switch statements can only evaluate integer and character data types.

For the hottest C jobs, please visit www.hirist.com

33

hirist
.com

QUESTION 33

QUESTION
What is gets() function?

ANSWER
The gets() function allows a full line data entry from the user. When the user presses the enter key to end the input,
the entire line of characters is stored to a string variable. Note that the enter key is not included in the variable, but
instead a null terminator \0 is placed after the last character.

For the hottest C jobs, please visit www.hirist.com

34

hirist
.com

QUESTION 34

QUESTION
Difference between Syntax and logical error?

ANSWER
Syntax error:
These involves validation of syntax of language
Compiler prints diagnostic message.
Logical error:
Logical error are caused by an incorrect algorithm or by a statement mistyped in such a way that it doesnt violet
syntax of language.
It is difficult to find.

For the hottest C jobs, please visit www.hirist.com

35

hirist
.com

QUESTION 35

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

For the hottest C jobs, please visit www.hirist.com

36

hirist
.com

QUESTION 36

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

For the hottest C jobs, please visit www.hirist.com

37

hirist
.com

QUESTION 37

QUESTION
Are Pointers Integer?

ANSWER
No, Pointers are not integers. A pointer is an address. It is a positive number.

For the hottest C jobs, please visit www.hirist.com

38

hirist
.com

QUESTION 38

QUESTION
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).

For the hottest C jobs, please visit www.hirist.com

39

hirist
.com

QUESTION 39

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

For the hottest C jobs, please visit www.hirist.com

40

hirist
.com

QUESTION 40

QUESTION
What is spaghetti programming?

ANSWER
Spaghetti programming refers to codes that tend to get tangled and overlapped throughout the program. This
unstructured approach to coding is usually attributed to lack of experience on the part of the programmer.
Spaghetti programing makes a program complex and analyzing the codes difficult, and so must be avoided as
much as possible.

For the hottest C jobs, please visit www.hirist.com

41

hirist
.com

QUESTION 41

QUESTION
In C programming, how do you insert quote characters ( and ) into the output
screen?
ANSWER
This is a common problem for beginners because quotes are normally part of a printf statement. To insert the quote
character as part of the output, use the format specifiers (for single quote), and (for double quote).

For the hottest C jobs, please visit www.hirist.com

42

hirist
.com

QUESTION 42

QUESTION
What is a nested loop?

ANSWER
A nested loop is a loop that runs within another loop. Put it in another sense, you have an inner loop that is inside an
outer loop. In this scenario, the inner loop is performed a number of times as specified by the outer loop. For each
turn on the outer loop, the inner loop is first performed.

For the hottest C jobs, please visit www.hirist.com

43

hirist
.com

QUESTION 43

QUESTION
Can the curly brackets { } be used to enclose a single line of code?

ANSWER
While curly brackets are mainly used to group several lines of codes, it will still work without error if you used it for a
single line. Some programmers prefer this method as a way of organizing codes to make it look clearer, especially
in conditional statements.

For the hottest C jobs, please visit www.hirist.com

44

hirist
.com

QUESTION 44

QUESTION
What are compound statements?

ANSWER
Compound statements are made up of two or more program statements that are executed together. This usually
occurs while handling conditions wherein a series of statements are executed when a TRUE or FALSE is
evaluated. Compound statements can also be executed within a loop. Curly brackets { } are placed before and
after compound statements.

For the hottest C jobs, please visit www.hirist.com

45

hirist
.com

QUESTION 45

QUESTION
What is a register variable?

ANSWER
Register variables are stored in the CPU registers. Its default value is a garbage value. Scope of a register variable
is local to the block in which it is defined. Lifetime is till control remains within the block in which the register
variable is defined. Variable stored in a CPU register can always be accessed faster than the one that is stored in
memory. Therefore, if a variable is used at many places in a program, it is better to declare its storage class as
register
Example: register int x=5;
Variables for loop counters can be declared as register. Note that register keyword may be ignored by some
compilers.

For the hottest C jobs, please visit www.hirist.com

46

hirist
.com

QUESTION 46

QUESTION
What is size of void pointer?

ANSWER
Size of any type of pointer in c is independent of data type which is pointer is pointing i.e. size of all type of pointer
(near) in c is two byte either it is char pointer, double pointer, function pointer or null pointer. Void pointer is not
exception of this rule and size of void pointer is also two byte.

For the hottest C jobs, please visit www.hirist.com

47

hirist
.com

QUESTION 47

QUESTION
What are printf and scanf, call by reference or call by value?

ANSWER
Printf : Call by value
Scanf : Call by reference

For the hottest C jobs, please visit www.hirist.com

48

hirist
.com

QUESTION 48

QUESTION
What is a const pointer?

ANSWER
a const pointer means the pointer which represents the address of one value. so if you declare a pointer inside the
function, it doesn't have scope outside the function. if it is also available to the outside function whenever we
declare a pointer as const.

For the hottest C jobs, please visit www.hirist.com

49

hirist
.com

QUESTION 49

QUESTION
Why does n++ execute much faster than n+1?

ANSWER
n++ takes more than one instruction, ++n is faster. n++ has to store n, increment the variable and return n, while
++n increment n and return without storing the previous value of n.

For the hottest C jobs, please visit www.hirist.com

50

hirist
.com

QUESTION 51

QUESTION
What is 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.

For the hottest C jobs, please visit www.hirist.com

51

hirist
.com

QUESTION 51

QUESTION
Why doesn't C support function overloading?

ANSWER
Overloading is polymorphism which is one of the characteristics of Object oriented programming. C is not and object
oriented language like C++ or Java. Therefore, no overloading, inheritance, etc.

For the hottest C jobs, please visit www.hirist.com

52

hirist
.com

QUESTION 52

QUESTION
What is an incomplete type?

ANSWER
Incomplete types refers to pointers in which there is non availability of the implementation of the referenced location
or it points to some location whose value is not available for modification.

For the hottest C jobs, please visit www.hirist.com

53

hirist
.com

QUESTION 53

QUESTION
Explain the Difference between C and C++?

ANSWER
C is the predecessor of C++. C++ is an Object Oriented, non-procedural language, unlike C, which is a procedural
language. C++ treats all data and functional handling in terms of Objects and their relationships.

For the hottest C jobs, please visit www.hirist.com

54

hirist
.com

QUESTION 54

QUESTION
What is Nesting in C?

ANSWER
Including one constructed inside another, is nesting. Nesting can be a structure inside another structure, an if-else
statement within another, multiple while loops, one inside the other. Continuing our earlier example, if you have a
collection of bikes, instead of grouping them separately, you can nest them within a main structure, which you can
name Collection of Bikes.

For the hottest C jobs, please visit www.hirist.com

55

hirist
.com

QUESTION 55

QUESTION
How is calloc () different from malloc ()?

ANSWER
The main difference between the two is that calloc (), when it is used to assign a block of memory, the allocated
contents are initialized to 0. Malloc (), on the other hand, does not initialise the memory block it assigns. The
memory just has random values left over from previous usage.

For the hottest C jobs, please visit www.hirist.com

56

hirist
.com

QUESTION 56

QUESTION
What are Destructors in C Language?

ANSWER
Classifying a destructor you can call it a class object and it is called a destructor once it goes out of scope or gets
deleted overtly. The job of a destructor is to put an end to objects being produced by a constructor. Just like the
constructor you can consider destructor a functional member and it is specifically known by a class name.

For the hottest C jobs, please visit www.hirist.com

57

hirist
.com

QUESTION 57

QUESTION
What are the uses of a pointer?

ANSWER
Pointer is used in the following cases
i) It is used to access array elements
ii) It is used for dynamic memory allocation.
iii) It is used in Call by reference
iv) It is used in data structures like trees, graph, linked list etc.

For the hottest C jobs, please visit www.hirist.com

58

hirist
.com

QUESTION 58

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

For the hottest C jobs, please visit www.hirist.com

59

hirist
.com

QUESTION 59

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

For the hottest C jobs, please visit www.hirist.com

60

hirist
.com

QUESTION 60

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

For the hottest C jobs, please visit www.hirist.com

61

hirist
.com

QUESTION 61

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

For the hottest C jobs, please visit www.hirist.com

62

hirist
.com

QUESTION 62

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

For the hottest C jobs, please visit www.hirist.com

63

hirist
.com

QUESTION 63

QUESTION
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 registered 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.

For the hottest C jobs, please visit www.hirist.com

64

hirist
.com

QUESTION 64

QUESTION
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).

For the hottest C jobs, please visit www.hirist.com

65

hirist
.com

QUESTION 65

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

For the hottest C jobs, please visit www.hirist.com

66

hirist
.com

QUESTION 66

QUESTION
What is a function?

ANSWER
A large program is subdivided into a number of smaller programs or subprograms. Each subprogram specifies one
or more actions to be performed for the larger program. Such sub programs are called functions.

For the hottest C jobs, please visit www.hirist.com

67

hirist
.com

QUESTION 67

QUESTION
What is an argument?

ANSWER
An argument is an entity used to pass data from the calling to a called function.

For the hottest C jobs, please visit www.hirist.com

68

hirist
.com

QUESTION 68

QUESTION
Write a program which employs Recursion?

ANSWER
int fact(int n) { return n > 1 ? n * fact(n 1) : 1; }

For the hottest C jobs, please visit www.hirist.com

69

hirist
.com

QUESTION 69

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

For the hottest C jobs, please visit www.hirist.com

70

hirist
.com

QUESTION 70

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

For the hottest C jobs, please visit www.hirist.com

71

hirist
.com

QUESTION 71

QUESTION
What do the functions atoi(), itoa() and gcvt() do?

ANSWER
atoi() is a macro that converts integer to character.
itoa() It converts an integer to string
gcvt() It converts a floating point number to string

For the hottest C jobs, please visit www.hirist.com

72

hirist
.com

QUESTION 72

QUESTION
How is fopen() used ?

ANSWER
The function fopen() returns a file pointer. Hence a file pointer is declared and it is assigned as
FILE *fp;
fp= fopen(filename,mode);
filename is a string representing the name of the file and the mode represents:
r for read operation
w for write operation
a for append operation
r+,w+,a+ for update operation

For the hottest C jobs, please visit www.hirist.com

73

hirist
.com

QUESTION 73

QUESTION
What is the purpose of ftell ?

ANSWER
The function ftell() is used to get the current file represented by the file pointer.
ftell(fp);
returns a long integer value representing the current file position of the file pointed by the
file pointer fp.If an error occurs ,-1 is returned.

For the hottest C jobs, please visit www.hirist.com

74

hirist
.com

QUESTION 74

QUESTION
Discuss on pointer arithmetic?

ANSWER
1.

Assignment of pointers to the same type of pointers.

2.

Adding or subtracting a pointer and an integer.

3.

Subtracting or comparing two pointer.

4.

Incrementing or decrementing the pointers pointing to the elements of an array. When a pointer to an integer is
incremented by one , the address is incremented by two. It is done automatically by the compiler.

5.

Assigning the value 0 to the pointer variable and comparing 0 with the pointer. The pointer having address 0
points to nowhere at all.

For the hottest C jobs, please visit www.hirist.com

75

hirist
.com

QUESTION 75

QUESTION
What is the invalid pointer arithmetic?

ANSWER
i) adding ,multiplying and dividing two pointers.
ii) Shifting or masking pointer.
iii) Addition of float or double to pointer.
iv) Assignment of a pointer of one type to a pointer of another type ?

For the hottest C jobs, please visit www.hirist.com

76

hirist
.com

QUESTION 76

QUESTION
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 (nor, under a pre-ANSI compiler, is there generally any way of initializing a union at all).

For the hottest C jobs, please visit www.hirist.com

77

hirist
.com

QUESTION 77

QUESTION
What is Output of following c snippet?
int main(){
char *s="Abhas";
printf("%s",s+ 2);
getch();
}

ANSWER
Has. Explanation: In the above program role of %s is to display the string whose address is passed as an
argument. This is how a standard printf statement works in c language. Now since we have passed s + 2 as an
argument therefore first value of this expression is evaluated. Here s would refer to address of first character in
string s. Now printf would get address of third character (address of first character + 2) as argument so it will
display the string starting from third position. Hence output would be has.

For the hottest C jobs, please visit www.hirist.com

78

hirist
.com

QUESTION 78

QUESTION
What is difference between .com program and .exe program?

ANSWER
Both .com and .exe program are executable program but .com program executes faster than .exe program. All
drivers are .com program. .com file has higher preference than .exe.

For the hottest C jobs, please visit www.hirist.com

79

hirist
.com

QUESTION 79

QUESTION
Describe turbo c Compiler?

ANSWER
Turbo c is an IDE programming language created by Borland. Turbo C 3.0 is based on MS DOS operation system. It
is one of the most popular c compilers. It uses 8086 microprocessor which is 16 bit microprocessor. It has 20
address buses and 16 data bus. Its word length is two byte.

For the hottest C jobs, please visit www.hirist.com

80

hirist
.com

QUESTION 80

QUESTION
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 ().

For the hottest C jobs, please visit www.hirist.com

81

hirist
.com

QUESTION 81

QUESTION
Differentiate between a for loop and a while loop?

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.

For the hottest C jobs, please visit www.hirist.com

82

hirist
.com

QUESTION 82

QUESTION
Is there a built-in function in C that can be used for sorting data?

ANSWER
Yes, use the qsort() function. It is also possible to create user defined functions for sorting, such as those based on
the balloon sort and bubble sort algorithm.

For the hottest C jobs, please visit www.hirist.com

83

hirist
.com

QUESTION 83

QUESTION
What are the advantages and disadvantages of a heap?

ANSWER
Storing data on the heap is slower than it would take when using the stack. However, the main advantage of using
the heap is its flexibility. Thats because memory in this structure can be allocated and remove in any particular
order. Slowness in the heap can be compensated if an algorithm was well designed and implemented.

For the hottest C jobs, please visit www.hirist.com

84

hirist
.com

QUESTION 84

QUESTION
How do you convert strings to numbers in C?

ANSWER
You can write you own functions to do string to number conversions, or instead use Cs built in functions. You can
use atof to convert to a floating point value, atoi to convert to an integer value, and atol to convert to a long integer
value.

For the hottest C jobs, please visit www.hirist.com

85

hirist
.com

QUESTION 85

QUESTION
Create a simple code fragment that will swap the values of two variables num1 and
num2.
ANSWER
int temp;
temp = num1;
num1 = num2;
num2 = temp;

For the hottest C jobs, please visit www.hirist.com

86

hirist
.com

QUESTION 86

QUESTION
What is the use of a semicolon (;) at the end of every program statement?

ANSWER
It has to do with the parsing process and compilation of the code. A semicolon acts as a delimiter, so that the
compiler knows where each statement ends, and can proceed to divide the statement into smaller elements for
syntax checking.

For the hottest C jobs, please visit www.hirist.com

87

hirist
.com

QUESTION 87

QUESTION
What does the characters r and w mean when writing programs that will make
use of files?
ANSWER
r means read and will open a file as input wherein data is to be retrieved. w means write, and will open a file
for output. Previous data that was stored on that file will be erased.

For the hottest C jobs, please visit www.hirist.com

88

hirist
.com

QUESTION 88

QUESTION
Which function in C can be used to append a string to another string?

ANSWER
The strcat function. It takes two parameters, the source string and the string value to be appended to the source
string.

For the hottest C jobs, please visit www.hirist.com

89

hirist
.com

QUESTION 89

QUESTION
What is the difference between functions getch() and getche()?

ANSWER
Both functions will accept a character input value from the user. When using getch(), the key that was pressed will
not appear on the screen, and is automatically captured and assigned to a variable. When using getche(), the key
that was pressed by the user will appear on the screen, while at the same time being assigned to a variable.

For the hottest C jobs, please visit www.hirist.com

90

hirist
.com

QUESTION 90

QUESTION
What does the function toupper() do?

ANSWER
It is used to convert any letter to its upper case mode. Toupper() function prototype is declared in <ctype.h>. Note
that this function will only convert a single character, and not an entire string.

For the hottest C jobs, please visit www.hirist.com

91

hirist
.com

QUESTION 91

QUESTION
What are run-time errors?

ANSWER
These are errors that occur while the program is being executed. One common instance wherein run-time errors can
happen is when you are trying to divide a number by zero. When run-time errors occur, program execution will
pause, showing which program line caused the error.

For the hottest C jobs, please visit www.hirist.com

92

hirist
.com

QUESTION 92

QUESTION
Is this program statement valid? INT = 10.50;

ANSWER
Assuming that INT is a variable of type float, this statement is valid. One may think that INT is a reserved word and
must not be used for other purposes. However, recall that reserved words are express in lowercase, so the C
compiler will not interpret this as a reserved word.

For the hottest C jobs, please visit www.hirist.com

93

hirist
.com

QUESTION 93

QUESTION
What is wrong with this program statement? void = 10;

ANSWER
The word void is a reserved word in C language. You cannot use reserved words as a user-defined variable.

For the hottest C jobs, please visit www.hirist.com

94

hirist
.com

QUESTION 94

QUESTION
What would happen to X in this expression: X += 15; (assuming the value of X is 5)

ANSWER
X +=15 is a short method of writing X = X + 15, so if the initial value of X is 5, then 5 + 15 = 20.

For the hottest C jobs, please visit www.hirist.com

95

hirist
.com

QUESTION 95

QUESTION
Not all reserved words are written in lowercase. TRUE or FALSE?

ANSWER
FALSE. All reserved words must be written in lowercase; otherwise the C compiler would interpret this as
unidentified and invalid.

For the hottest C jobs, please visit www.hirist.com

96

hirist
.com

QUESTION 96

QUESTION
What is floating point constants?

ANSWER
Floating-point constants are numbers with decimal parts. A floating-point constants consists of :

An integral part

A decimal point

A fractional part

An exponent part

An optional suffix

For the hottest C jobs, please visit www.hirist.com

97

hirist
.com

QUESTION 97

QUESTION
What is the difference between fread and fwrite function?

ANSWER
The fread() function returns the number of items read. This value may be less than count if the end of the file is
reached or an error occurs. The fwrite() function returns the number of items written. This value will equal count
unless an error occurs.

For the hottest C jobs, please visit www.hirist.com

98

hirist
.com

QUESTION 98

QUESTION
What is meant by inheritance?

ANSWER
Inheritance is the process by which objects of one class acquire properties of objects of another class.

For the hottest C jobs, please visit www.hirist.com

99

hirist
.com

QUESTION 99

QUESTION
What is a ternary operator in C?

ANSWER
Perhaps the most unusual operator in C language is one called the conditional expression operator. Unlike all other
operators in C which are either unary or binary operators the conditional expression operator is a ternary operator;
that is, it takes three operands. The two symbols that are used to denote this operator are the question mark (?)
and the colon (:). The first operand is placed before the ?, the second between the ? and the and the third after
the:.

For the hottest C jobs, please visit www.hirist.com

100

hirist
.com

QUESTION 100

QUESTION
What is unary operator?

ANSWER
The operators that act upon a single operand to produce a new value are known as unary operators.

For the hottest C jobs, please visit www.hirist.com

101

hirist
.com

Resources

http://www.fresherventure.net/frequently-asked-c-language-interview-questionsand-answers/
http://www.itechaleart.com/2014/06/top-100-c-interview-qa.html
http://placement.freshersworld.com/power-preparation/technical-interviewquestions/C-programming-answers-21419
http://career.guru99.com/top-100-c-interview-questions-answers/
http://www.slideshare.net/vineetkumarsaini/top-c-language-interview-questionsand-answer
http://www.cquestions.com/2010/10/c-interview-questions-and-answers.html
http://placementsindia.blogspot.com/2007/10/basic-c-interview-questions.html
https://www.udemy.com/blog/c-programming-questions/
http://crackaninterview.com/c-language-interview-questions/
http://www.cwithabhas.com/2013/09/simple-c-interview-questions-for-mass.html
http://www.freejobalert.com/c-interview-questions/2891/

For the hottest C jobs, please visit www.hirist.com

102

www.hirist.com

TOPC 100
INTERVIEW QUESTIONS & ANSWERS

Você também pode gostar