the answers do not appear.... how should i put formula correctly?
# include %26lt;iostream.h%26gt;
int main ()
{
//conditional statement
int l;
int w;
int a;
int p;
cout%26lt;%26lt;"enter the length:";
cin%26gt;%26gt;l;
cout%26lt;%26lt;"enter the width:";
cin%26gt;%26gt;w;
if (l%26lt;=w)
{a=l*w;
cout%26lt;%26lt;"the area of the rectangle is:";
cout%26lt;%26lt;endl;}
else(l%26gt;w);
{p=2*l+2*w;
cout%26lt;%26lt;"the perimeter of the rectangle is:";
cout%26lt;%26lt;endl;}
return 0;
}
C++ putting formula?
else(l%26gt;w);
remove the semikolon
also, you don't print the result, you just print
cout %26lt;%26lt; "the area of the rectangle is: ";
instead of
cout %26lt;%26lt; "the area of the rectangle is: " %26lt;%26lt; a;
Reply:try with writing
#include%26lt;conio.h%26gt;
after the #include%26lt;iostream.h%26gt;
if the problem not solved contact me i will provide u another program for this
Reply:in your else statement, you shouldn't explicitly say:
else(l%26gt;w)
else() is enough...unless of course you wanted to say:
else if(l%26gt;w)...but from your code i didn't get that impression.
Reply:u should also print out the variable 'p' which is ur final answer
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment