- 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
Functions in C Interview Questions & Answers - Learning Mode

Functions in C Interview Questions & Answers - Learning Mode

A function is a group of statements that together perform a task. Every C program has at least one function, which is main(), and all the most trivial programs can define additional functions. You can divide up your code into separate functions. In general, functions are blocks of code that perform a number of pre-defined commands to accomplish something productive. You can either use the built-in library functions or you can create your own functions. Functions that a programmer writes will generally require a prototype.

Try Functions in C Interview Questions & Answers - Exam Mode

1 2 3 Next

Sort By : Latest First | Oldest First | By Rating

Functions in C Interview Questions & Answers - Learning Mode
Try Functions in C Interview Questions & Answers - Exam Mode
Question: Can you use the function fprintf()to display the output on the screen?

Question: What is a static function?

Answer: A static function is a function whose scope is limited to the current source file. Scope refers to the visibility of a function or variable. If the function or variable is visible outside of the current source file, it is said to have global, or external, scope. If the function or variable is not visible outside of the current source file, it is said to have local, or static, scope. Source:
Question: Is using exit() the same as using return?

Answer: No. The exit() function is used to exit your program and return control to the operating system. The return statement is used to return from a function and return control to the calling function. If you issue a return from the main() function, you are essentially returning control to the calling function, which is the operating system. In this case, the return statement and exit() function are similar. Source:
Question: What are the advantages of the functions?

Answer: ?Debugging is easier<br><br>?It is easier to understand the logic involved in the program<br><br>?Testing is easier<br><br>?Recursive call is possible<br><br>?Irrelevant details in the user point of view are hidden in functions<br><br>?Functions are helpful in generalizing the program Source:
Question: How would you use the functions randomize()and random()?

Question: How to use floodfill() function and what is the use of kbhit?

Answer: Flood-fills a bounded region

Declaration: void far floodfill(int x, int y, int border);

floodfill fills an enclosed area on bitmap devices.

The area bounded by the color border is flooded with the current fill
pattern and fill color.

(x,y) is a "seed point".
? If the seed is within an enclosed area,
the inside will be filled.
? If the seed is outside the enclosed area,
the exterior will be filled.
floodfill does not wor Source:
Question: 1. what is a difference between printf and cout . and why printf called a function and cout object as both are used to print data?

Answer: In high level terms, the main differences are type safety (cstdio
doesn't have it), performance (most iostreams implementations are
slower than the cstdio ones) and extensibility (iostreams allows
custom output targets and seamless output of user defined types). Source:
Question: How to see return value of main function?

Answer: //this code will print return value of main
static unsigned int nCount = 0;
void NoReturnFunc();
int main()
if(0 == nCount)

return 0;

void NoReturnFunc()
int nRetValue = main();
printf("Return by main %d",nRetValue);
} Source:
Question: Differentiate between a linker and linkage?

Answer: A linker converts an object code into an executable code by linking together the necessary build in functions. The form and place of declaration where the variable is declared in a program determine the linkage of variable. Source:
Question: How do we get Square root of any number Without using sqrt() function?

Answer: You can use a iterative method for example bisection

#include <stdio.h>
int n;
float eval=1.0,x1=0,x2=n,x; //trying to locate root between x1=0 and x2=n and giving a initial dummy value to eval
printf("Enter value for n n n");
while((eval > 0.0001 )||( eval < -0.0001) ) { //you can change accuracy by changing 0.0001 to smaller value
eval= x*x-n;
printf(" eval = %f t",eval); //printf to keep track not n Source:
Question: Have you heard of "mutable" keyword?

Answer: The mutable keyword can only be applied to non-static and non-const data members of a class. If a data member is declared mutable, then it is legal to assign a value to this data member from a const member function.



class Mutable
private :
int m_iNonMutVar;
mutable int m_iMutVar;

void TryChange() const;


Mutable::Mutable():m_i Source:
Question: How to write a program in c to print its own code?

Answer: //prog.c
void main()
char ch;
FILE *fp;
unable to open file");
} Source:
Question: How can send unlimited no of arguments to a function, eg printf function can take any no of arguments

Answer: using va_list variables in stdarg.h headerfile Source:
Question: What is the code for clrscr() function?

Answer: clrscr() is a function which creates a screenful of black dots which seems us to be clearing the screen or making a new screen. Source:
Question: What are returned by printf(), scanf() functions,if they return anything means what are that?

Answer: Return type of printf() and scanf() is integer. scanf() returns the no.of variables used and printf() returns the total no.of bytes.
Question: What is the purpose of main( ) function?

Answer: The function main( ) invokes other functions within it.It is the first function to be called when the program starts execution.

?It is the starting function

?It returns an int value to the environment that called the program

?Recursive call is allowed for main( ) also.

?It is a user-defined function

?Program execution ends when the closing brace of the function main( ) is reached.

?It has two arguments 1)argument count and 2) argument vector (repre Source:
Question: What is the difference between goto and longjmp() and setjmp()?

Answer: A goto statement implements a local jump of program execution, and the longjmp() and setjmp() functions implement a nonlocal, or far, jump of program execution.

Generally, a jump in execution of any kind should be avoided because it is not considered good programming practice to use such statements as goto and longjmp in your program.

A goto statement simply bypasses code in your program and jumps to a predefined position. To use the goto statement, you give it a labeled position t Source:
Question: How to use the cprintf,cscanf,sscanf,sprintf,vsscanf,vsprintf,vscanf & vprintf?

Answer: cprintf:This function sends the formatted output to the text window on the screen.
cscanf:This function reads reads from the standard input device directly,avoiding buffering both by DOS and by the library.
sprintf: This function sends formatted output to the string.
sscanf: This function scans formatted text from the string and stores i on the variables pointed to by the arguments.
vprintf: This function sends formatted output to stdin,using an argument list.
vscanf: This functio Source:
Question: how would you use the functions memcpy(),memset(),memmove()?

Question: How would you use bsearch()function to search a name stored in array of pointers to string?


1 2 3 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.015625 Seconds