i want rpogramming code for --> acceptive value from user and find out square of the no. in c++
@rohya, what do you mean by āacceptiveā?
i think you want to accept a number from user and print square of that number isnāt it? What difficulty are you facing? please elaborate so that you get better help
But for now hereās the c++ code:
#include<iostream>
using namespace std;
int main()
{
int a;
cout<<"enter the number";
cin>>a;
int square= a*a;
cout<< "The square is: " << square;
return 0;
}
this code will work in software borland c++?
and yes itās accept not acceptiveā¦ typing error.
please just let me know is this code will work in software borland c++?
Ok, so since you asked i just installed Borland c++(version 3.1) for the first time.
important points to be noted:
- In Borland while using header files you must use .h extension. while, coding for online environments like codehcef or spoj never use .h extensions.
- You can not use "using namespace std" in Borland( I think)
and here is your answer, working code for finding square in borland with ouput:
Hope this helps!
thank you so much broā¦
will you be help me out with this
question is : Accept number from user and find out cube of the number.
this also i want to be run in borland ā¦ plz try if you canā¦
i didnt got plz can you please show throught code
In the above code:
Replace:
<pre> int square= a * a;
with:
<pre> int cube= a * a * a;
everything else remains the same.
ya image one only used in borland but showing thi error
#include<iostream>
void main()
{
int a;
cout<<"enter the number"<<end1;
cin>>a;
int cube;
cube=a*a*a;
cout<<"The cube of the number is: " << cube;
}
output:
Line 2: error: ā::mainā must return āintā
@rohya well, now you can follow the code in the image. iām sure it wont be difficult to make out that cube of number = aaa so you just need to add multiply the square one more time with āaā and you have the cube!
Why on earth would you use Borland when you have Code Blocks and Visual Studio?