CoolInterview.com - World's Largest Collection of Interview Questions & Answers, FAQs, queries, sample papers, exam papers, dumps, what, why, how, where, when questions OneStopTesting.com - Testing EBooks, Tutorials, Articles, Jobs, Training Institutes etc.
OneStopGate.com - Gate EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopMBA.com - MBA EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopIAS.com - IAS EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopSAP.com - SAP EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.
OneStopGRE.com - of GRE EBooks, Tutorials, Articles, FAQs, Jobs, Training Institutes etc.

Sponsored Links

Interview Questions
Our Services



INTERVIEW QUESTIONS C FUNCTIONS IN C DETAILS
Question :

Is using exit() the same as using return?

Category Functions in C Interview Questions
Rating (4.4) By 57 users
Added on 10/22/2009
Views 6065
Rate it!


Answers:

Source: CoolInterview.com

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: CoolInterview.com



Source: CoolInterview.com

Prototype of atexit() is :
int atexit ( void ( * function ) (void) );

The function pointed by the function pointer argument is called when the program terminates normally.

If more than one atexit function has been specified by different calls to this function, they are all executed in reverse order as a stack, i.e. the last function specified is the first to be executed at exit.

One single function can be registered to be executed at exit more than once.



/* atexit example */
#include <stdio.h>
#include <stdlib.h>

void fnExit1 (void)
{
puts ("Exit function 1.");
}

void fnExit2 (void)
{
puts ("Exit function 2.");
}

int main ()
{
atexit (fnExit1);
atexit (fnExit2);
puts ("Main function.");
return 0;
}

Output:

Main function.
Exit function 2.
Exit function 1.

//Here the output is in reverse order as a stack, i.e. the last function specified is the first to be executed at exit.

Source: CoolInterview.com



Posted by: Syed Baseer Ahmed

Contact Syed Baseer Ahmed Contact Syed Baseer Ahmed

Source: CoolInterview.com

exit() is used for to exit the control from the program. but return() return the values to main or functions. it never terminate the program.
Source: CoolInterview.com



Posted by: aravind

Contact aravind Contact aravind

Source: CoolInterview.com

Exit and return serves differnt purposes.
Exit is used to terminate the calling program while return is used to return the value to calling program
eg
int sum(int a, int b);
main()
int a,b,c;
printf("Enter the value of a and b);
scanf("%d %d",&a,&b);
c=sum(a,b);
exit(0);
printf("Sum is %d",c);
}
int sum(int a, int b)
{
int d;
d=a+b;
return(d);
}
in this bcause of exit function the output will not be displayed but if we delete line exit(0) then we will get output
Source: CoolInterview.com



Posted by: Ruchi

Contact Ruchi Contact Ruchi

If you have the better answer, then send it to us. We will display your answer after the approval.
Rules to Post Answers in CoolInterview.com:-
  • There should not be any Spelling Mistakes.
  • There should not be any Gramatical Errors.
  • Answers must not contain any bad words.
  • Answers should not be the repeat of same answer, already approved.
  • Answer should be complete in itself.
Name :*
Email Id :*
Answer :*
Verification Code Code Image - Please contact webmaster if you have problems seeing this image code Not readable? Load New Code
Process Verification Enter the above shown code: *
Inform me about updated answers to this question

Related Questions
View Answer
Differentiate between a linker and linkage?
View Answer
What is a function and built-in function?
View Answer
What is an argument ? differentiate between formal arguments and actual arguments?
View Answer
What is the purpose of main( ) function?
View Answer
What are the advantages of the functions?
View Answer
What is a method?
View Answer

Please Note: We keep on updating better answers to this site. In case you are looking for Jobs, Pls Click Here Vyoms.com - Best Freshers & Experienced Jobs Website.

View ALL Functions in C Interview Questions & Answers



User Options
India News Network

Latest 20 Questions
What is Corporate Tax Planning?
What are the Corporate Tax rebates applicable in India?
What is Corporate Tax Rate for Foreign Companies in India?
What is Corporate Tax Rate for Domestic Companies in India?
What is meant by Income of a Company?
What is meant by a Corporate?
How Corporate Tax is levied in India?
What are various categories of Corporate Taxes?
What is Corporate Tax?
What is the scope of Securities Transaction Tax (STT)?
What is meant by Securities, in case of Securities Transaction Tax (STT)?
What are taxable transactions in case of Securities Transaction Tax (STT)?
Give an example of Securities Transaction Tax (STT)?
When is Securities Transaction Tax levied?
What is the difference between Securities Transaction Tax (STT) and Income Tax?
What are the securities on which STT is applicable?
What is the Securities Transaction Tax (STT) Rate in India?
What are the main features of Securities Transaction Tax (STT)?
What is Securities Transaction Tax, STT?
What is the rate of Securities Transaction Tax (STT)?



Fresher Jobs | Experienced Jobs | Government Jobs | Walkin Jobs | Company Profiles | Interview Questions | Placement Papers | Companies In India | Consultants In India | Colleges In India | Exams In India | Latest Results | Notifications In India | Call Centers In India | Training Institutes In India | Job Communities In India | Courses In India | Jobs by Keyskills | Jobs by Functional Areas

Testing Articles | Testing Books | Testing Certifications | Testing FAQs | Testing Downloads | Testing Interview Questions | Testing Jobs | Testing Training Institutes

Gate Articles | Gate Books | Gate Colleges | Gate Downloads | Gate Faqs | Gate Jobs | Gate News | Gate Sample Papers | Gate Training Institutes

MBA Articles | MBA Books | MBA Case Studies | MBA Business Schools | MBA Current Affairs | MBA Downloads | MBA Events | MBA Notifications | MBA FAQs | MBA Jobs
MBA Job Consultants | MBA News | MBA Results | MBA Courses | MBA Sample Papers | MBA Interview Questions | MBA Training Institutes

GRE Articles | GRE Books | GRE Colleges | GRE Downloads | GRE Events | GRE FAQs | GRE News | GRE Training Institutes | GRE Sample Papers

IAS Articles | IAS Books | IAS Current Affairs | IAS Downloads | IAS Events | IAS FAQs | IAS News | IAS Notifications | IAS UPSC Jobs | IAS Previous Question Papers
IAS Results | IAS Sample Papers | IAS Interview Questions | IAS Training Institutes | IAS Toppers Interview

SAP Articles | SAP Books | SAP Certifications | SAP Companies | SAP Study Materials | SAP Events | SAP FAQs | SAP Jobs | SAP Job Consultants
SAP Links | SAP News | SAP Sample Papers | SAP Interview Questions | SAP Training Institutes |




Copyright ©2003-2016 CoolInterview.com, All Rights Reserved.
Privacy Policy | Terms and Conditions



Cache = 0 Seconds