int main()
{
const int PRIME=11213;
const RATE=15.6;
int i, x, y, w;
x=7;
y=3;
x= x+w;
PRIME= x+PRIME;
cout%26lt;%26lt; PRIME%26lt;%26lt;endl;
wages=RATE*36.75;
cout%26lt;%26lt; "Wages= " %26lt;%26lt; wages %26lt;%26lt;endl;
return 0;
whats wrong with this?
C++ question!?
1. int main()
2. {
3. const int PRIME=11213;
4. const RATE=15.6;
5. int i, x, y, w;
6. x=7;
7. y=3;
8. x= x+w;
9.
10. PRIME= x+PRIME;
11. cout%26lt;%26lt; PRIME%26lt;%26lt;endl;
12. wages=RATE*36.75;
13. cout%26lt;%26lt; "Wages= " %26lt;%26lt; wages %26lt;%26lt;endl;
14.
15. return 0;
-----
you use wages variable without declaration .
for example:
you have declare (x,y,w) at line 5 "int x,y,w;"
you have to declare wages:
double wages;
Reply:There are a lot of errors with your code
const RATE=15.6;
This should be const DOUBLE RATE, since its 15.6;
PRIME= x+PRIME;
PRIME is a const, meaning your not allowed to change its value, so using that line is not correct.
cout%26lt;%26lt; "Wages= " %26lt;%26lt; wages %26lt;%26lt;endl;
there's is no such thing as "wages"
I've posted the corrections to the code
#include %26lt;iostream%26gt;
using namespace std;
int main()
{
int PRIME= 11213;
const double RATE = 15.6;
int i, x, y, w;
x=7;
y=3;
x= x+w;
double wages = 0;
PRIME= x+PRIME;
cout%26lt;%26lt; PRIME%26lt;%26lt;endl;
wages=RATE*36.75;
cout%26lt;%26lt; "Wages= " %26lt;%26lt; wages %26lt;%26lt;endl;
return 0;
}
This displays:
"-858982240
Wages= 573.3"
cout%26lt;%26lt; PRIME%26lt;%26lt;endl; = "-858982240"
The reason for this is because you did not give a value to "w"
In order to correct this, just make w = 0;
cout%26lt;%26lt; "Wages= " %26lt;%26lt; wages %26lt;%26lt;endl; = "Wages= 573.3"
Which is what you hoped to get, I hope :P
Good luck programming
Feel free to msg me when you don't understand something, ill be gald to answer your question to the best of my ablilty
Reply:when u solve the c++ programs take it easy and think easy
its sure u achieve it bcoz this ur world
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment