User input/output

Page 1 of 1

1 Replies - 1530 Views - Last Post: 13 October 2008 - 02:18 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=67421&amp;s=46f52ac2d3d0ee25bd74a75a9cdd3db0&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 bbarker3

Reputation: 1
• Posts: 33
• Joined: 12-October 08

User input/output

Posted 13 October 2008 - 02:10 PM

I have my assignment finished, but is there any other option for user input and the outputs? (Simple first assignment. 1.Greet User. 2. Have user input radius in cm. 3. Inputs the radius. 4. Outputs the volume of the sphere.)

```#include <stdio.h>
#include <iostream>
#include <math.h>

using namespace std;

int main(void)
{
cout << "Welcome\n";
cout << "The Volume of the sphere is \n" << (4 * 3.14159 * pow(sphereRadius, 3))/3 << "\n";
return(0);

}
```

If possible, maybe go without having to use the #include <iostream>? I know for 'cout', I can just use printf("Welcome\n");, but anything I can differently with 'cin'?

Is This A Good Question/Topic? 0

Replies To: User input/output

#2 Gloin

• Expert Schmexpert...

Reputation: 235
• Posts: 4,489
• Joined: 04-August 08

Re: User input/output

Posted 13 October 2008 - 02:18 PM

Just as there's printf, there's a cin equivalent in scanf.

scanf("%i" , &i); <-- puts an integer into the variable i