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

Previous 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: How to reduce a final size of executable ?

Answer: Size of the final executable can be reduced using dynamic linking for libraries. Source: CoolInterview.com
Question: Output of this Programme please??

main()
{

int a[]={2,4,6,8,10};
int i;
change(a,5);
for(int i=0;i<=4;i++)
printf(" %d", a[i]);
}

change(int *b,int n)
{

int i;
for(i=0;i *(b+i) = *(b+i)+5;
}

sytaxis correct?? was asked i a test




Answer: I think the syntax is incorect in the for loop of the change function, it sould have atleast a closing ')'.

Secondly, if the function defination is given after the function calling, then the proper prototype of the function must be declared before the calling of the function, other wise compiler declares a default prototype by considering each parameters as well as the return type as integer, which leads into the compiler error "type mismatch in redeclaration of the function".
Source: CoolInterview.com
Question: Between n+1 and n++ which executes faster or both take the same time to execute?

Answer: n++ will be faster because in this case there will be only one variable in memory whereas in n+1, there will be two. Source: CoolInterview.com
Question: main()
{
char *a = "Hello ";
char *b = "World";
clrscr();
printf("%s", strcat(a,b));
}




Answer: It may print HelloWorld but concat using strcat(a,b) is not safe becoz it is not known waht is written in memory beyond "hello" and we are trying to attach "world" beyond "hello" so it may lose some important data . Source: CoolInterview.com
Question: What is the purpose of realloc( ) ?

Answer: 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 n specifies the new size.

The size may be increased or decreased. If n is greater than the old size and if sufficient space is not available subsequent to the old region, the function realloc( ) may create a new region and all the old data are moved to the new region. Source: CoolInterview.com
Question: What is the draw back in using friend function in c++


Answer: In c++, friend function is a big draw back.friend function is only function which are not member of any class and can access private variable of same class.This breaks the concept of 'DataHiding' In OOP.That is reason so that java is not implemented friend function concept. Source: CoolInterview.com
Question: Write a program which accepts a filename as a command line argument and reverses the contents of the file( ie first character

becomes the last character of the file and so on)


Input: The program takes the file name whose content should be reversed.

Output: The program reverses the contents of the file.





Answer: #include #include int main(int argc, char *argv[]){ int fd, i, fsize; char *first=(char *) malloc(1); char *last=(char *) malloc(1); if (argc != 2) { printf("pass two argumentsn"); exit (-1); } /* Open the file */ fd = open(argv[1], O_RDWR); if (fd == -1) { printf("error in file openingn"); exit (-1); }#ifdef PRINT printf("File Open Sucessn");#endif /* Find the file size */ fsize = lseek(fd, 0, SEEK_END);#ifdef PRINT printf("File Size = %dn", fsize);#endif /* Reverse the file */ for (i=0; i Source: CoolInterview.com
Question: How to write a program for pascal triangle?

Answer: int fact(int n)
{
int i,fact=1;
for(i=1;i<=n;i++)
fact*=i;
return fact;
}
int c(int n,int r)
{
int val;
val=fact(n)/(fact(r)*fact(n-r));
void main()
{
int i,j,k,no;
printf("Enter Number";
scanf("%d",&no);
for(i=1;i<=n;i++)
{
for(j=0;j<=n-i+1;j++)
printf(" ");
for(k=0;k<=i;k++)
printf("%d ",c(i,k);
printf("
");
}
}
Source: CoolInterview.com
Question: How abstraction done in C?

Answer: using storage classes... Source: CoolInterview.com
Question: How can numbers be separated by comma in C?(1200 - 1,200)
The number can be up to 9 digits.


Answer: No answer available currently.
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: If the following program (myprog) is run from the command line as myprog friday tuesday sunday,
What would be the output?

main(int argc, char *argv[])
{
printf("%c",*++argv[1]);
}






Answer: Correct answer is r. Source: CoolInterview.com
Question: Can there be a mouse click and drag function used in c?

Answer: no Source: CoolInterview.com
Question: union u
{
struct st
{
int i : 4;
int j : 4;
int k : 4;
int l;
}st;
int i;
}u;
main()
{
u.i = 100;
printf("%d, %d, %d",u.i, u.st.i, u.st.l);
}



Answer: Ans is B)100,4,0because in structures&unions varible initilization is not possible.but bit by bit is possible.here :isbitwise operator. Source: CoolInterview.com
Question: Write character a to z in random seqence in one dimensional array then how to get 'ABC' and then directly get the 'PQR' ?

Answer: No answer available currently.
Question: When should the volatile modifier be used ?

Answer: The volatile modifier is a directive to the compiler?s optimizer that operations involving this variable should not be optimized in certain ways. There are two special cases in which use of the volatile modifier is desirable. The first case involves memory-mapped hardware (a device such as a graphics adaptor that appears to the computer?s hardware as if it were part of the computer?s memory), and the second involves shared memory (memory used by two or more programs running simultaneously). Source: CoolInterview.com
Question: What are the advantages of pointers,give me programs containing variables and pointer variables?

Answer: POINTER IS JUST LIKE A VARIABLE WHICH HOLDS THE ADDRES OF ANOTHER VARIABLE.POINTER IS DENOTED BY ASTERIK(*) SIGN.POINTER HAVE VERY IMPORTANT USE IN 'C' LANGUAGE.
/*PROGRAM DEMONSTRATES THE CONCEPT OF POINTER */
#include <stdio .h>
#include<conio.h>
void main()
{
int a=10;
int *m;//pointer type declaration
clrscr();
printf("the value of a==%d",a);
printf("the value of a==%d",*m);
printf("the adres of a==%u",&a);
printf("the adres of a==%u",m Source: CoolInterview.com
Question: What is Preprocessor ?

Answer: The preprocessor is used to modify your program according to the preprocessor directives in your source code.

Preprocessor directives (such as #define) give the preprocessor specific instructions on how to modify your source code. The preprocessor reads in all of your include files and the source code you are compiling and creates a preprocessed version of your source code.

This preprocessed version has all of its macros and constant symbols replaced by their corresponding code and Source: CoolInterview.com
Question: If we want that any wildcard characters in the command line argument should be approxiemately expanded , are we required to make any special provision?if yes, which?

Answer:
Question: main()
{
int i;
clrscr();
printf("%d", &i)+1;
scanf("%d", i)-1;
}





Answer: Runtime error. Access violation. Source: CoolInterview.com

Previous 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.109375 Seconds