- 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: How would you use the functions randomize()and random()?

Question: How to print a statement without using printf() in c?

Answer: using getchar()
int i;
char c;
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: 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: 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: How do you use a pointer to a function?

Answer: The hardest part about using a pointer-to-function is declaring it.

Consider an example. You want to create a pointer, pf, that points to the strcmp() function.

The strcmp() function is declared in this way:

int strcmp(const char *, const char * )

To set up pf to point to the strcmp() function, you want a declaration that looks just like the strcmp() function?s declaration, but that has *pf rather than strcmp:

int (*pf)( const char *, const char * );

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

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: 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: 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 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: What is an argument ? differentiate between formal arguments and actual arguments?

Answer: An argument is an entity used to pass the data from calling function to the called function. Formal arguments are the arguments available in the function definition.They are preceded by their own data types.Actual arguments are available in the function call. Source:
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: What is the output of
void main()
int a = (1,2,3);

with reason.

Answer: The answer is 3

The value which is last in the bracket is assigned to a(the variable).If it would have been any other value except 3,then it would have been assigned to 'a'. Source:
Question: Write a program with out using
main() function?

Answer: #include<stdio.h>

#define decode(s,t,u,m,p,e,d) m##s##u##t
#define begin decode(a,n,i,m,a,t,e)

int begin()
printf(" hello ");

Question: How argc and argv works in the following main function?

main(int argc,char *argv[])
{ int n,i=0;

Answer: *****main can recieve its own arguments but in a preconditioned way: main (int argc, char **argv) { ............ }*****% a.out 1 my_input argc is 3 argv[0] = "a.out" argv[1]="1" argv[2]="my_input" Source:
Question: What is a method?

Answer: Method is a way of doing something, especially a systematic way; implies an orderly logical arrangement (usually in steps). Source:
Question: In c , main() is a function . and where is defined main() in c. bcz every function has three parts.
1>. decleration
2>. definition.
3>. calling

Answer: Declaration is not needed if method is defined before calling.main() method is called by the OS when the program is run.So, it has only a definition.. 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: 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:

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.5 Seconds