You are not logged in. Please login at www.codechef.com to post your questions!

×

[closed] i want help in programming coding in c++

0
1

i want rpogramming code for --> acceptive value from user and find out square of the no. in c++

asked 01 Jul '13, 17:19

rohya's gravatar image

0★rohya
11236
accept rate: 0%

closed 01 Jul '13, 20:17

sunny_patel's gravatar image

2★sunny_patel
1.3k31025

The question has been closed for the following reason "The question is answered, right answer was accepted" by sunny_patel 01 Jul '13, 20:17


@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;
}
link

answered 01 Jul '13, 17:28

sunny_patel's gravatar image

2★sunny_patel
1.3k31025
accept rate: 19%

edited 01 Jul '13, 17:30

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! :)

link

answered 01 Jul '13, 18:28

sunny_patel's gravatar image

2★sunny_patel
1.3k31025
accept rate: 19%

edited 01 Jul '13, 18:29

Why on earth would you use Borland when you have Code Blocks and Visual Studio? :p

(29 Jan '14, 21:07) vigonoid1★

thank you so much bro.. :) :D 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..

link

answered 01 Jul '13, 18:37

rohya's gravatar image

0★rohya
11236
accept rate: 0%

@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!

(01 Jul '13, 18:40) sunny_patel2★

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++?

link

answered 01 Jul '13, 17:47

rohya's gravatar image

0★rohya
11236
accept rate: 0%

alt text

So, since you asked, for the first time i installed the Borlnad compiler and this is the working code with the output of your program!
Important changes to be observed:

  • header in Borland includes ".h" extension whereas it is not to be used ever on any online environment like codechef or spoj
  • omit using namespace std;

hope this helps! :)

link

answered 01 Jul '13, 18:11

sunny_patel's gravatar image

2★sunny_patel
1.3k31025
accept rate: 19%

for cubing use the same code as above...and instead of aa...use aa*a...that will be it..hope this helps..:)

link

answered 01 Jul '13, 18:42

kunal361's gravatar image

4★kunal361
6.0k133272
accept rate: 21%

i didnt got plz can you please show throught code

link

answered 01 Jul '13, 18:42

rohya's gravatar image

0★rohya
11236
accept rate: 0%

In the above code:
Replace:

 int square= a * a;
with:
 int cube= a * a * a;

everything else remains the same.

link

answered 01 Jul '13, 19:12

sunny_patel's gravatar image

2★sunny_patel
1.3k31025
accept rate: 19%

edited 01 Jul '13, 19:12

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'

:(

link

answered 01 Jul '13, 19:45

rohya's gravatar image

0★rohya
11236
accept rate: 0%

edited 01 Jul '13, 19:48

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'

link

answered 01 Jul '13, 19:49

rohya's gravatar image

0★rohya
11236
accept rate: 0%

edited 01 Jul '13, 20:06

kunal361's gravatar image

4★kunal361
6.0k133272

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×1,818
×1,441
×1,311
×1,201
×905
×242

question asked: 01 Jul '13, 17:19

question was seen: 2,862 times

last updated: 29 Jan '14, 21:07