CoolInterview.com - 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
COOLINTERVIEW.COM PROGRAMMING LANGUAGES INTERVIEW QUESTIONS C INTERVIEW QUESTIONS 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)
printf("c");
else
printf("c++");
}
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: CoolInterview.com
Question: What is page thrashing?

Answer: Some operating systems (such as UNIX or Windows in enhanced mode) use virtual memory. Virtual
memory is a technique for making a machine behave as if it had more memory than it really has, by using disk space to simulate RAM (random-access memory). In the 80386 and higher Intel CPU chips, and in most other modern microprocessors (such as the Motorola 68030, Sparc, and Power PC), exists a piece of hardware called the Memory Management Unit, or MMU.

The MMU treats memory as if it were co Source: CoolInterview.com
Question: main()
{
extern int i;
i=20;
printf("%d",i);
}




Answer: Linker Error : Undefined symbol '_i'
Explanation:
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 .

Source: CoolInterview.com
Question: How to find GCD of four numbers?

Answer: Take 4 numbers.The smallest number has to be found out.Then divide each number by that numbers which are less than that smallest number.
e.g.5,15,75,20
smallest-5
so divide each numbers by 1,2,3,4,5.
The GCD will be that number which divides all the number.(here 5) Source: CoolInterview.com
Question: main()
{
if (!(1&&0))
{
printf("OK I am done.");
}
else
{
printf("OK I am gone.");
}
}




Answer: OK I am done
Source: CoolInterview.com
Question: Write a program to remove comment lines and blank lines from an error free c program.

Answer: NOTE: THIS PROGRAM WILL ONLY REMOVE THE COMMENTS (/*...*/) BUT NOT THE BLANK LINES.A PROGRAM 2 REMOVE COMMENTS AS WELL AS BLANK LINES WILL B SUBMITTED SOOOOON.THANKS.HERE'S DA PROGRAM



#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<dos.h>
void main()
{
FILE *a,*b;
char fname[20],ch,tch=NULL;
int flag1=0,flag=0,count=0;
clrscr();
printf("Enter the file name (.C or .TXT)
");
gets(fname);
a=fopen(fnam Source: CoolInterview.com
Question: #define SQR(x) x * x
main()
{
printf("%d", 225/SQR(15));
}




Answer: Use typical C coding guidelines and use

#define SQR(x) ((x) * (x))

And you get the desired answer: 1

Source: CoolInterview.com
Question: What are enumerations?

Answer: enumerations is one type of user defined data type Source: CoolInterview.com
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
(1101)(1001)(0011)(1100)
Hence the given set of bits can be converted to HEXA DECIMAL SYSTEM
as
(D93C)
16 Source: CoolInterview.com
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: CoolInterview.com
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: CoolInterview.com
Question: What is a default TCP/IP socket assigned for SQL Server?

Answer:
Question: What is difference between the test effort and the test procedure?

Answer: Both are different concepts. Test effort defines how much time required to execute a particular test case. Test procedure defines the required actions to execute that test case.
Source: CoolInterview.com
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)
printf("%s",*++argv);
}






Answer: B, it will print "mondaytuesdaywednesdaythursday" Source: CoolInterview.com
Question: main()
{
int i=3;
switch(i)
{
default:printf("zero");
case 1: printf("one");
break;
case 2:printf("two");
break;
case 3: printf("three");
break;
}
}




Answer: The output will be three because when execution takes place ,inside the switch the corresponding case 3(since i=3)is selected and as there is a break statement after it, it cmes out of the loop. Source: CoolInterview.com
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.

Source: CoolInterview.com
Question: main()
{
int x=5;
clrscr();
for(;x==0;x--) {
printf("x=%dn?", x--);
}
}




Answer: The condition x==0 is never satisfied so it prints nothing.


Source: CoolInterview.com
Question: What will be the output of the following program in UNIX OS with CC compiler and TC compiler?

int main()
{
int i=5;
printf(" %d",++i + ++i + ++i + ++i + ++i );
}
If any difference then Why it is difference?




Answer:

Output: 41.


For different compiler ther will be same output.

Expression will be evaluated in following manner.
(((++i + ++i) + ++i) + ++i) + ++i
6
7
7 + 7 = 14
8
14 + 8 = 22
9
22 + 9 = 31
10
31 + 10 = 41.

Source: CoolInterview.com
Question: The program that outputs the given binary or image file

Answer: #include<stdio.h>
#include<stdlib.h>
int main(int argc,char *argv[])
{
char c;
FILE* fp=fopen(argv[0],"r");
if(fp==NULL)
{
perror(argv[0]);
exit(1);
}

while((c=fgetc(fp))!=EOF)
fputc(c,stdout);
}
Source: CoolInterview.com
Question: #include<conio.h>
main()
{
int x,y=2,z,a;
if(x=y%2) z=2;
a=2;
printf("%d %d ",z,x);
}


Answer: Answer:
Garbage-value 0
Explanation:
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.

Source: CoolInterview.com

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