What is the problem in the following, I cannot run it because it has 17 erros..?????????
/*************************************...
Radius of a circle
This program calculates the radius of a cirle
**************************************...
#include %26lt;iostream%26gt;
using namespace std;
const float PI = 3.141593
int main()
{
float numbera;
float numberb;
float numberc;
float sum;
float radius;
cout %26lt;%26lt; "Enter an integer or a decimal number: ";
cin %26gt;%26gt; numbera;
cout %26lt;%26lt; "Enter a second integer or a decimal number: ";
cin %26gt;%26gt; numberb;
cout %26lt;%26lt; "Enter a third integer or a decimal number: ";
cin %26gt;%26gt; numberc;
sum = numbera + numberb + numberc;
radius = float(sum)/2 * PI;
cout %26lt;%26lt; "The radius is " %26lt;%26lt; radius %26lt;%26lt; endl;
return 0;
}
Need help with a C++ program I'm creating. I thought it would be easy but it's not.?
1.Multi line comments (as you have placed at the top) start with /* and end with */ .
2.Put a semi-colon ( ; ) after the statement:
const float PI = 3.141593
3.You are using the latest ANSI C++ IDE. So, you have to include std: before the cout and cin objects.
The correct program will look something like this:
/* __________ __Your comments_ _________
______here_______ ______ */
#include %26lt;iostream%26gt;
using namespace std;
const float PI = 3.141593;
int main()
{
float numbera;
float numberb;
float numberc;
float sum;
float radius;
std:cout %26lt;%26lt; "Enter an integer or a decimal number: ";
std:cin %26gt;%26gt; numbera;
std:cout %26lt;%26lt; "Enter a second integer or a decimal number: ";
std:cin %26gt;%26gt; numberb;
std:cout %26lt;%26lt; "Enter a third integer or a decimal number: ";
std:cin %26gt;%26gt; numberc;
sum = numbera + numberb + numberc;
radius = (sum/2) * PI;
std:cout %26lt;%26lt; "The radius is " %26lt;%26lt; radius %26lt;%26lt; endl;
return 0;
}
If the const statement doesn't work, just define Pi like this:
#define PI 3.141593
and place it just below the #include %26lt;iostream%26gt; line.
:)
Reply:Don't pay too much attention to the number of errors reported by a compiler. Once they get confused, they tend to stay confused for a bit.
You have a comment which is unterminated. You are missing a semicolon at the end of a statement. These are likely the only two errors you have. I'll let you hunt a bit, rather than giving you the exact answer, as you will need to learn to track these things down.
Reply:u forgot sum semi-colons, getch();
im in ninth grade i took c++ for 1 semister, its over now
Reply:radius = float(sum)/2 * PI;
A while since i've done C++ but i really dont think u should put "float" on that statement.
Reply:#include %26lt;iostream.h%26gt;
dont forget the .h at the end
baseball cards
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment