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:
main()
{
char * strA;
char * strB = I am OK;
memcpy( strA, strB, 6);
}































Answer: I fthe string is declared in the double codes then it will. Source: CoolInterview.com
Question: Write a program to accept any number up to six digit and print in words.
for ex:1234=one two three four


Answer: #include<stdio.h>
void main()
{
long int number,r,rev=0,rem;
printf("Enter any number");
scanf("%ld",&number);
while(number!=0)
{
r=number%10;
rev=(rev*10)+r;
number/=10;
}
while(rev!=0)
{
rem=rev%10;
switch(rem)
{
case 1:
printf("one ");
break;
case 2:
printf("two ");
break;
case 3:
printf("three ");
break;
case 4:
printf("four ");
break;
Source: CoolInterview.com
Question: Would the following program compile?

main()
{
int a=10,*j;
void *k;
j=k=&a;
j++;
k++;
printf("n%u%u",j,k);
}






Answer: It will compile..but prints some garbage value. Source: CoolInterview.com
Question: How do you write a C program which can calculate lines of code but not counting comments?



Answer: Using file concept with Command line arguments.declare a variable (lcnt) used to count the no of lines.Open a file in read made and then using while loop check the condition for not equal to EOF.Later using if condition check check for new line and increment the variable for counting the lines.

Then using while,check for the character '/','*' (as the comments start with these characters) and end with ('*' and '/').if condition of this is true then break and Source: CoolInterview.com
Question: Can we have nested header files in C?

Answer: Yes, its perfectly possible to have nested header files in C. Source: CoolInterview.com
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: In which line of the following, an error would be reported?
1. #define CIRCUM(R) (3.14*R*R);
2. main()
3. {
4. float r=1.0,c;
5. c= CIRCUM(r);
6. printf("n%f",c);
7. if(CIRCUM(r))==6.28)
8. printf("nGobbledygook");
9. }




Answer: The correct answer is B(Line 5). #define CIRCUM(R) (3.14*R*R);means wherever the program encounters CIRCUM(R) replace it with (3.14*R*R); including the semicolon. So the line number 5 will have 2 semicolons continuosly.Got it... Source: CoolInterview.com
Question: main()
{
printf("%d, %d", sizeof('c'), sizeof(100));
}




Answer: The answer is 2,2 coz sizeof return the memory occupied and "c" uses 1 byte to store character 'c' and the other byte to store NULL to indicate the end of string. 100 being stored as an interger would take 2 bytes Source: CoolInterview.com
Question: main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%dn", bit = (bit >> (i - (i -1))));
}
}




Answer: Ans is Bbecause the will b terminated after i=0;bit>>(i-(i-1)))means first it assignsi=5.the first value for bit is512>>(5-(5-1))=512>>1=512/2/1=256 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: main()
{
char *p = "hello world";
p[0] = 'H';
printf("%s", p);
}




Answer: Answer is B) Hello World.p[0] is just replacing the value on the first index. Source: CoolInterview.com
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

#include

in your program, the file macros.inc 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: CoolInterview.com
Question: What is the output of the following program?

#define SQR(x) (x*x)

main()

{

int a,b=3;

a= SQR(b+2);

printf("%d",a);

}





Answer: The ans is B(11).

Since it passes like (3+2) to #define, where it calculates as

(3+2 * 3+2), as Ist preference is multiply & then addition, it evalvates as

(3+ 2 * 3 +2) = (3+6+2)=11.
Source: CoolInterview.com
Question: What is the function of % using in formatted string.

Answer: The next character is a conversional character. and these two characters are replaced by the value of the variable in the argument list when displayed. 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: main()
{
char c;
int i = 456;
clrscr();
c = i;
printf("%d", c);
}




Answer: it takes more than one byte. Se when we assign c=i, the most significant will be lost. Then the value of c is 11001000. when you print the value of c using %d(signed integer), the most significat bit will be considered as the +/-. Here it is 1 and hence the number is negative. Negative numbers are in 2's compliment form. so converting back, we will get 00111000. ie, -56 in decimal. if you used %u instead of %d, you could have got 200.
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: #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: How to connect a database (MS Access) to Borland C?
Please give me step by step coding.


Answer: No answer available currently.
Question: What would be the output of the following program?

main()
{
char near * near *ptr1;
char near * far *ptr2;
char near * huge *ptr3;
printf("%d %d %d",sizeof(ptr1),sizeof(ptr2),sizeof(ptr3));
}






Answer: Correct answer is 244 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.046875 Seconds