problem with program

closed account (2wv7M4Gy)
I made this program my self , it works but when it shows the result ιτ repeats ""Can't accept negative numbers or 0 " even if the numbers are correct . What's the problem ?


#include <iostream>
#include <math.h>

using namespace std;
int main()
{
float r , p , s;
float P=3.14;

do
{
cout<<"r=";
cin>>r;
if (r<=0);
cout<<"Can't accept negative numbers or 0 "<<endl;
}
while (r<=0);

p=2*P*r;
s=P*pow(r,2);

cout<<"The perimeter is : " <<p<<endl;
cout<<"The area is : " <<s<<endl;

system ("pause");
return 0;
}



if anyone could help me i would appreciate it !
As I said at http://www.cplusplus.com/forum/beginner/6376/
Remove the semicolon after the if condition:
1
2
if (r<=0);//<-- this to be removed
cout<<"Can't accept negative numbers or 0 "<<endl;

PS: Please don't open new discussions on already existing subjects
Topic archived. No new replies allowed.