further help with my final project program

Further help regarding this code, im trying to make a program that compute radius and the output will be diameter and area and vice versa for the others but first i need to figure out how to finish radius.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include<iostream.h>
#include<conio.h>

int main(void)
{
int choice, radius, diameter, area;

cout<<"Enter your Choice: "<<endl;
cout<<"1. Radius "<<endl;
cout<<"2. Diameter "<<endl;
cout<<"3. Area "<<endl:

cout<<"Enter desired number: "<<endl;
cin>>choice;

//for radius
if(choice==1)
{
const double PI=3.14159;

double radius;

cout<<"Input number: "<<endl;
cin>>radius;

double diameter=2*radius;
double area=PI*radius*radius;

//output for radius
cout<<"The Area and Diameter is "<<endl;
cout<<"Area="<<area<<endl;
cout<<"Diameter="<<diameter<<endl;
}
clrscr();
return 0;
}


i can already run the program but after inputing my desired radius, the program will suddenly shutdown and go back to where im encoding the codes.
tried to delete the clrscr() and saw that the program actually converts it but the main problems is as i stated, "After i INPUT the radius, it will go back to where i encode it. pls can anyone state whats wrong with this?

thx very much. :D
sry if my question is somewhat repetitive.
Last edited on
Hi there,

After i INPUT the radius, it will go back to where i encode it


What do you mean by "encode" exactly?
Calling clrsrc() will clear the entire console window of any text (or move any text upwards until it looks that way), so it may seem like nothing has happened. Is that what you are referring to?

All the best,
NwN
sorry if i said it in a very vague manner, the part of the C++ where we write the code, the blue background one.

i just tried removing the clrsrc(), that time i saw that my program works since it will not erase the previous right? saw that my program converted the radius and the above supposed output appeared there.

my real problem regards to the radius. where in line 24 where i supposed to input the radius to be converted, "After i input the number" it will go back to the blue background where we type the codes.

sry if i cant really explain it very well.
Last edited on
Ahh. looks like old beginner problem: http://www.cplusplus.com/forum/beginner/1988/

I suggest to search for option in your IDE which will keep console open or change IDE.
tried the suggestions in that specific link, its very informative but it didnt help my problem. it still go back to the main screen whenever i input a number to be converted.
Topic archived. No new replies allowed.