Hai I have written this code.Its working fine when i execute in pelles.But when i open .exe file After i enter radius it is closing with in a second.Please help.
MY CODE IS
#include <stdio.h>
#define PI 3.1419
int main()
{
float area , radius ;
printf("Enter the radius of the circle in cms.");
scanf("%f",&radius);
area = PI * radius * radius;
printf("The area of a circle is %f sq.cms.",area);
printf("A Progrramm devoloped by Nishanth. ");
printf("Thank you for using ");
printf("Press Esc to exit");
return 0;
}
When you run a console program by clicking on it the console window closes as soon as the program exits.
This leaves you 2 choices...
1) Open a CMD prompt in the program's folder and run it by typing in it's name and hitting enter.
2) Add an extra line of code...
printf("Press any key to exit");
getchar(); <-- add this.
return 0;
The getchar() call will hold the console window open until you press a key on your keyboard...
You may also have to add a getchar() after your call to scanf() since it leaves the Enter key in the keyboard buffer.