- World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions
Our Services
Get 9,000 Interview Questions & Answers in an eBook.

Get it now !!
Send your Resume to 6000 Companies
C Interview Questions & Answers - Learning Mode

C Interview Questions & Answers - Learning Mode

C is a high-level and general purpose programming language that is ideal for developing firmware or portable applications. Originally intended for writing system software, C was developed at Bell Labs by Dennis Ritchie for the Unix Operating System (OS) in the early 1970s. With the increasing popularity of object-oriented programming, C is being rapidly replaced as "the" programming language by C++, a superset of the C language that uses an entirely different set of programming concepts, and by Java, a language similar to but simpler than C++, that was designed for use in distributed networks.

Try C Interview Questions & Answers - Exam Mode
Subcategories for C Interview Questions & Answers - Learning Mode

Following are sub categories for which Interview Questions & Answers are available under C Interview Questions & Answers - Learning Mode. Please select the appropriate sub-category:-

Arrays in C Interview Questions & Answers (18) Learning Mode | Exam Mode

Branches & Loops in C Interview Questions & Answers (22) Learning Mode | Exam Mode

C Basics Interview Questions & Answers (92) Learning Mode | Exam Mode

Dynamic Memory Allocation in C Interview Questions & Answers (21) Learning Mode | Exam Mode

File Operations in C Interview Questions & Answers (16) Learning Mode | Exam Mode

Functions in C Interview Questions & Answers (59) Learning Mode | Exam Mode

Operators in C Interview Questions & Answers (22) Learning Mode | Exam Mode

Pointers in C Interview Questions & Answers (43) Learning Mode | Exam Mode

Strings in C Interview Questions & Answers (32) Learning Mode | Exam Mode

Structures in C Interview Questions & Answers (39) Learning Mode | Exam Mode

Variables in C Interview Questions & Answers (39) Learning Mode | Exam Mode

1 2 3 4 5 6 7 8 Next

Sort By : Latest First | Oldest First | By Rating

C Interview Questions & Answers - Learning Mode
Try C Interview Questions & Answers - Exam Mode
Question: void main()
float a= 0.7;
if (a < 0.7)
Output of the above program is c. Why? Whereas the same program with 0.8 instead of 0.7 gives c++ as the output? Why explain?

Answer: If you give value greater than .7 then it will go 2 the else part because .8 is not less than .7 Source:
Question: main()
extern int i;

Answer: Linker Error : Undefined symbol '_i'
extern storage class in the following declaration,
extern int i;
specifies to the compiler that the memory for i is allocated in some other program and that address will be given to the current program at the time of linking. But linker finds that no other variable of name i is available in any other program with memory space allocated for it. Hence a linker error has occurred .

Question: Write a program to remove comment lines and blank lines from an error free c program.


void main()
FILE *a,*b;
char fname[20],ch,tch=NULL;
int flag1=0,flag=0,count=0;
printf("Enter the file name (.C or .TXT)
a=fopen(fnam Source:
Question: How to find size of an datatype without using sizeof operator?

Answer: This should return the size of the datatype without using sizeof()

datatype x;

size = (&x - (&x +1)) Source:
Question: main()
int i=5;

Answer: Answer:<br>45545<br>Explanation:<br>The arguments in a function call are pushed into the stack from left to right. The evaluation is by popping out from the stack. and the evaluation is from right to left, hence the result.<br><br> Source:
Question: To which numbering system can the binary number 1101100100111100 be easily converted to?

Answer: Since this is a 16 bit number,
we can group these bits into 4bits a group each as
Hence the given set of bits can be converted to HEXA DECIMAL SYSTEM
16 Source:
Question: When should a type cast be used?

Answer: There are two situations in which to use a type cast. The first use is to change the type of an operand to an arithmetic operation so that the operation will be performed properly.

The second case is to cast pointer types to and from void * in order to interface with functions that expect or return void pointers. For example, the following line type casts the return value of the call to malloc() to be a pointer to a foo structure.

struct foo *p = (struct foo *) malloc(sizeof(struc Source:
Question: main()
char *p;
printf("%d %d ",sizeof(*p),sizeof(p));

Answer: Ans :1,2 because the *p is the pointer varible but the type is character.p is apointer variable.

Question: #define int char
int i=65;

Answer: Answer:<br> sizeof(i)=1<br>Explanation:<br>Since the #define replaces the string int by the macro char <br><br> Source:
Question: void main()
int const * p=5;

Answer: Answer:
Compiler error: Cannot modify a constant value.
p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".
Question: #include<conio.h>
int x,y=2,z,a;
if(x=y%2) z=2;
printf("%d %d ",z,x);

Answer: Answer:
Garbage-value 0
The value of y%2 is 0. This value is assigned to x. The condition reduces to if (x) or in other words if(0) and so z goes uninitialized.
Thumb Rule: Check all control paths to write bug free code.

Question: What are the standard predefined macros ?

Answer: The ANSI C standard defines six predefined macros for use in the C language:
Macro Name Purpose

_ _LINE_ _ Inserts the current source code line number in your code.
_ _FILE_ _ Inserts the current source code filename in your code.
_ _ Inserts the current date of compilation in your code.
_ _TIME_ _ Inserts the current time of compilation in your code.
_ _STDC_ _ Is set to 1 if you are enforcing strict ANSI C conformity.
_ _cplusplus Is defined if you are compiling a C++ Source:
Question: What would be the output of the following program?

int y=128;
const int x=y;

Answer: Correct ans is A) 128 Source:
Question: Which mistakes are called as token error?

Answer: Syntax or Parse errors before a Token are called as token error. Source:
Question: Can a file other than a .h file be included with #include ?

Answer: The preprocessor will include whatever file you specify in your #include statement. Therefore, if you have the line


in your program, the file will be included in your precompiled program. It is, however, unusual programming practice to put any file that does not have a .h or .hpp extension in an #include statement.

You should always put a .h extension on any of your C files you are going to include. This method makes it easier for you and others to identi Source:
Question: If the following program (myprog) is run from the command line as myprog monday tuesday wednesday thursday
What would be the output?

main(int argc, char *argv[])
while(--argc >0)

Answer: B, it will print "mondaytuesdaywednesdaythursday" Source:
Question: What is the result of using Option Explicit ?

Answer: When writing your C program, you can include files in two ways.
The first way is to surround the file you want to include with the angled brackets < and >.
This method of inclusion tells the preprocessor to look for the file in the predefined default location.
This predefined default location is often an INCLUDE environment variable that denotes the path to your include files.
For instance, given the INCLUDE variable
using the #i Source:
Question: When should the register modifier be used? Does it really help?

Answer: The register modifier hints to the compiler that the variable will be heavily used and should be kept in the CPU?s registers, if possible, so that it can be accessed faster.

There are several restrictions on the use of the register modifier.

First, the variable must be of a type that can be held in the CPU?s register. This usually means a single value of a size less than or equal to the size of an integer. Some machines have registers that can hold floating-point numbers as well. Source:
Question: According to ANSI specifications which is the correct way of declaring main() when it receives command line arguments?

Answer: main(int argc, char *argv[]) Source:
Question: union u1
int i;
char c;
now the i value gets replaced.
If we want to know the data that is saved in the union..internally, without knowing what values that we are using in the prog.

that is if just want to know whether a union currently holds an int or a char? If it is a combination of both int and char..we must know even that. and the memory locations at which this data is stored?

Answer: enum with_tag {int_tag, char_tag};

struct with_tag{

enum with_tag tag;

union {

int i;

char c;

} twoUnion;

} sampleStruct;

So, when assigning new int values:

sampleStruct.tag = int_tag;

sampleStruct.twoUnion.i = 3;

when assigning new char vaules:

sampleStruct.tag = char_tag;

sampleStruct.twoUnion.c = 'C';


1 2 3 4 5 6 7 8 Next

India News Network
Latest 20 Questions
Payment of time- barred debt is: (a) Valid (b) Void (c) Illegal (d) Voidable
Consideration is defined in the Indian Contract Act,1872 in: (a) Section 2(f) (b) Section 2(e) (c) Section 2(g) (d) Section 2(d)
Which of the following is not an exception to the rule, "No consideration, No contract": (a) Natural love and affection (b) Compensation for involuntary services (c) Completed gift (d) Agency
Consideration must move at the desire of: (a) The promisor (b) The promisee (c) The promisor or any other party (d) Both the promisor and the promisee
An offer which is open for acceptance over a period of time is: (a) Cross Offer (b) Counter Offer (c) Standing Offer (d) Implied Offer
Specific offer can be communicated to__________ (a) All the parties of contract (b) General public in universe (c) Specific person (d) None of the above
_________ amounts to rejection of the original offer. (a) Cross offer (b) Special offer (c) Standing offer (d) Counter offer
A advertises to sell his old car by advertising in a newspaper. This offer is caleed: (a) General Offer (b) Special Offer (c) Continuing Offer (d) None of the above
In case a counter offer is made, the original offer stands: (a) Rejected (b) Accepted automatically (c) Accepted subject to certain modifications and variations (d) None of the above
In case of unenforceable contract having some technical defect, parties (a) Can sue upon it (b) Cannot sue upon it (c) Should consider it to be illegal (d) None of the above
If entire specified goods is perished before entering into contract of sale, the contract is (a) Valid (b) Void (c) Voidable (d) Cancelled
______________ contracts are also caled contracts with executed consideration. (a) Unilateral (b) Completed (c) Bilateral (d) Executory
A offers B to supply books @ Rs 100 each but B accepts the same with condition of 10% discount. This is a case of (a) Counter Offer (b) Cross Offer (c) Specific Offer (d) General Offer
_____________ is a game of chance. (a) Conditional Contract (b) Contingent Contract (c) Wagering Contract (d) Quasi Contract
There is no binding contract in case of _______ as one's offer cannot be constructed as acceptance (a) Cross Offer (b) Standing Offer (c) Counter Offer (d) Special Offer
An offer is made with an intention to have negotiation from other party. This type of offer is: (a) Invitation to offer (b) Valid offer (c) Voidable (d) None of the above
When an offer is made to the world at large, it is ____________ offer. (a) Counter (b) Special (c) General (d) None of the above
Implied contract even if not in writing or express words is perfectly _______________ if all the conditions are satisfied:- (a) Void (b) Voidable (c) Valid (d) Illegal
A specific offer can be accepted by ___________. (a) Any person (b) Any friend to offeror (c) The person to whom it is made (d) Any friend of offeree
An agreement toput a fire on a person's car is a ______: (a) Legal (b) Voidable (c) Valid (d) Illegal
Cache = 0.046875 Seconds