i want help in programming coding in c++

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 :slight_smile:

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;
}
1 Like

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:

    alt text

    Hope this helps! :slight_smile:

3 Likes

thank you so much bro… :slight_smile: :smiley:
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…

1 Like

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? :stuck_out_tongue: