Home Format Memory Card Best Rangoli Designs Earn Money on Net Make A Blog Popular

Exit() function in C++

exit function : is terminates entire program. Here it is used in for loop when the value of i is eqauls to 100 then exit(0) will be executed and the program will be terminated.

#include<iostream.h>
#include<conio.h>
#include<process.h> // requires to include for exit() function
main()
{
clrscr();
for (int i=1;i<=100; i++)
{
cout << i <<endl;
if (i==30)
exit(0); // it will termiate entire program
}
cout << "hello" <<endl; // this statement will never execute.
getch();
}

1 comments:

Robin said...

some program doesnt run in c and there should be more meaning ful using pictorial representation