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: Can we print values from 1 to 100 without using for,while,do-while,if etc.?answer should be logical.

Answer: just give 1 to 100 numbers in a printf statement, Source: CoolInterview.com
Question: If the following program (myprog) is run from the command line as myprog 1 2 3, What would be the output?

main(int argc, char *argv[])
{
int i,j=0;
for(i=0;i<argc;i++)
j=j+ atoi(argv[i]);
printf("%d",j);
}





Answer: Ans B)6

Source: CoolInterview.com
Question: Where is the prototype of the main function i.e how the execution startd from main function and how to find out the size of a function.

Answer: prototype of main
int main(int argc, char *argv[]) or
void * main(int argc, char *argv[])
c language use top to bottom approach
so execution start from main function then it uses another function
in bottom up approach execution start from small functions to main function Source: CoolInterview.com
Question: When does the compiler not implicitly generate the address of the first element of an array ?

Answer: Whenever an array name appears in an expression such as
array as an operand of the sizeof operator
array as an operand of & operator
array as a string literal initializer for a character array.
Then the compiler does not implicitly generate the address of the address of the first element of an array.

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: How would you obtain the current time and difference between two times?

Answer:
Question: Q.8 When a 'C' function call is made, the order in which parameters passed to the function are pushed into the stack is
(a) left to right
(b) right to left
(c) bigger variables are moved first than the smaller variables.
(d) smaller variables are moved first than the bigger ones
(c) none of the above.


Answer: LIFO 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.
CoolInterview.com
Question: main(int x).............

explaination on arguments passed thr' main



Answer: The main function can have the command linre arguments like in this syntax main(int x)......

the main function can have two arguments

1. int x : tell the number of arguments in the main function that are given on the command line

2. char *array[] :it is an array of pointers to the string and specify the file names thay you want to pass on the command line.
Source: CoolInterview.com
Question: What is the difference between a string copy (strcpy) and a memory copy (memcpy)? When should each be used?

Answer: The strcpy() function is designed to work exclusively with strings. It copies each byte of the source string to the destination string and stops when the terminating null character () has been moved.
On the other hand, the memcpy() function is designed to work with any type of data. Because not all data ends with a null character, you must provide the memcpy() function with the number of bytes you want to copy from the source to the destination. Source: CoolInterview.com
Question: If the program (myprog) is run from the command line as myprog 1 2 3 , What would be the output?

main(int argc, char *argv[])
{
int i;
for(i=0;i<argc;i++)
printf("%s",argv[i]);
}






Answer: Right answer is B:because argv is char string which store command line as input and argc is int counter which give the length of this string. Source: CoolInterview.com
Question: I WANT DISPLAY

1111
1222
1233
1234

SEND ME ANS PLZZZZZZZ


Answer: #include"stdio.h"
#include"conio.h"
#include"stdlib.h"
void main()
{
clrscr();
for(int i=1,j;i<=5;++i)
{
switch(i)
{
case 1:
for(j=1;j<=4;j++)
{
printf("%d ",i);
}
break;
case 2:
for(j=1;j<=4;j++)
{
if(j<=1)
{
printf("%d ",j);
}
else
{
printf("%d ",i);
}}
break;
case 3:
for(j=1;j<=4;j++)
{
if(j<=2)
{
printf("%d ",j);
}
else
{
printf("%d ",i);
}}
break;
case 4: Source: CoolInterview.com
Question: Write a C program that will convert Simple Sentence to Complex/Compound Sentence.

Answer: No answer available currently.
Question: Can you tell me how to check whether a linked list is circular ?

Answer: Create two pointers, and set both to the start of the list. Update each as follows:
while (pointer1) {
pointer1 = pointer1->next;
pointer2 = pointer2->next;
if (pointer2) pointer2=pointer2->next;
if (pointer1 == pointer2) {
print ("circular");
}
}

If a list is circular, at some point pointer2 will wrap around and be either at the item just before pointer1, or the item before that. Either way, its either 1 or 2 jumps until they meet.

Source: CoolInterview.com
Question: Write down the equivalent pointer expression for reffering the same element a[i][j][k][l]?

Answer: *(*(*(*(a+i)+j)+k)l) Source: CoolInterview.com
Question: main()
{
int i = 0xff ;
printf("n%d", i<<2);
}




Answer: output is 1020since oXff is in hexadecimal form .decimal equivalent of it is 255.so 255<<2 is equivalent multiplication by 4 ie.1020 Source: CoolInterview.com
Question: I want C program code for : Reverse the links of a linked list by traversing only once

Input:
The input consists of the information in each node of the linked list.

Output:
The program displays the information in the linked list after the links are reversed.

Sample Input:
Enter the information in the linked list (Enter -1 to exit): 10
20
30
40
50
-1


Sample Output:
After the links are reversed
Information in the linked list:
50
40
30
20
10






Answer: #include <stdio.h>
#include <malloc.h>
#include <conio.h>


struct Node
{
int a;
Node *next;
};


Node* ReverseList( Node ** List );

void main()
{

struct Node *root,*n,*p;

root=(Node*)malloc(sizeof(Node));
root->a=10;
root->next=NULL;
n=root;
p=(Node*)malloc(sizeof(Node));
p->a=20;
p->next=NULL;
n->next=p;
n=p;
p=(Node*)malloc(sizeof(Node));
p->a=30;
p-& Source: CoolInterview.com
Question: 1.WRITE A 'C' PROGRAM TO READ THE AGE OF 100 PERSONS AND COUNT THE NUMBER OF PERSONS IN THE AGE GROUP 50 TO 60.USE FOR LOOP AND CONTINUE STATEMENTS.(10 MARKS)
2.WRITE A PROGRAM TO READ A POSITIVE INTEGER AND PRINT ITS BINARY EQUIVALENT.(10 MARKS)
3.GIVEN TWO ONE DIMENSIONAL ARRAYS A AND B WHICH ARE SORTED IN ASSCENDING ORDER.WRITE A PROGRAM TO MERGE THEM INTO A SINGLE SORTED ARRAY ,C THAT CONTAINS EVERY ITEM FROM ARRAYS A AND B,IN ASCENDING ORDER.(10 MARKS)
4.WRITE A FUNCTION IN C THAT WOULD TRAVERSE A LINEAR SINGLY LINKED LIST IN REVERSE AND WRITE OUT THE CONTENTS IN REVERSE ORDER.(10 MARKA)
5.WRITE A PROGRAM TO READ A SET OF INTEGERS AND TO SEPARATE ALL ODD AND EVEN NUMBERS .WRITE ALL EVEN NUMBERS IN ASCENDING ORDER.(10 MARKS)
6.WRITE A PROGRAM TO READ A REAL NUMBER X ANF FIND THE EVEN NUMBER NEAREST TO X.(10 MARKS)
7.WRITE A PROGRAM TO MULTIPLY TWO MATRICES OF ORDER M*N AND N*P RESPECTIVELY.(10 MARKS)
8.WRITE A PROGRAM IN'C' TO IMPLEMENT K-MAP SIMPLIFICATION TECHNIQUE.(10 MARKS)



Answer: I am having a recursive solution to the 2nd problem, though, one can find a non-recursive solution thru the implementation of stack.

void printBinary(int n)
{
if (n>0)
{
printBinary(n/2);
printf("%c","01"[n%2]);
}
else
{
printf(" ");
}
}
Source: CoolInterview.com
Question: #include <stdio.h>
int main()
{

int a=3, b = 5;
printf(&a["Ya!Hello! how is this? %s
"], &b["junk/super"]);
printf(&a["WHAT%c%c%c
%c%c
%c !
"], 1["this"],
2["beauty"],0["tool"],0["is"],3["sensitive"],4["CCCCCC"]);

return 0;
}


Answer: Hello! how is this? superThatisC !

Becoz &a will set ptr to 3rd position ie. at H and will print whole string
&b will set ptr to 5th position ie. @ s it also print whole string.
But in 2nd printf , string will start from 3rd position ie. T and will replace all %c with index which is outside of square bracket from the string inside square bracket. Source: CoolInterview.com
Question: Range of int in is -32768 to 32767 and it occupy 2 byte in memory and char take 1 byte take single char but in java int is 4 byte take value-2,147,483648 to 647 and char occupy 2 byte and also take single variable why not more?`



Answer: Because in java 2 byte is required to represent a single character because java use UNICODE to represent its character. 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