C and Cpp

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsDesktop ProgrammingC and Cpp

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old September 22nd, 2010, 02:45 AM
misfit956 misfit956 is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Sep 2010
Posts: 1 misfit956 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 9 m 27 sec
Reputation Power: 0
I'm a Noob and need help with my homework

Hello,
I'm currently taking a C++ class and not understanding a whole lot. I was given this assignment and not understanding how to go about this. It reads:

Develop a C++ program that shows on the console the volume of a sphere with radius r. The Program shows, in one line, the radius value, the volume as a real, the volume as integer and two most significant digits of the fractional part of the volume.

Concepts: Use of constants and variables and data type conversion.)

Help Please

Reply With Quote
  #2  
Old January 17th, 2011, 06:23 AM
infant_coder infant_coder is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jan 2011
Posts: 1 infant_coder User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 22 m 45 sec
Reputation Power: 0
Take New project in MS VS 2010, win32 console project.

#include "stdafx.h"
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
int radius,volume;
cout << endl << "Enter the radius of the sphere: " ;
cin >> radius;

volume = (4 * 3.14*radius*radius*radius)/3;
cout <<endl <<"Volume of sphere is " <<volume;
system("PAUSE");
return 0;
}

Reply With Quote
  #3  
Old November 19th, 2013, 09:07 AM
galecharm galecharm is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Nov 2013
Posts: 1 galecharm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 m 59 sec
Reputation Power: 0
Quote:
Originally Posted by misfit956
Hello,
I'm currently taking a C++ class and not understanding a whole lot. I was given this assignment and not understanding how to go about this. It reads:

Develop a C++ program that shows on the console the volume of a sphere with radius r. The Program shows, in one line, the radius value, the volume as a real, the volume as integer and two most significant digits of the fractional part of the volume.

Concepts: Use of constants and variables and data type conversion.)

Help Please




Its as follows:



//----------------------------------------------------------------------------------------------------------

#include< iostream>

#include< iomanip >
using namespace std;

int main()
{
int r;
float volume;
cout<<"Please enter the Radius of the Sphere";
cin>>r;
volume = (4/3) * (3.14) * (r * r * r);
//First print the real value of volume

cout << "Real Value of VOLUME : " << volume << endl;



//Second print the volume value as Integer we have used typecasting

cout << "Integer Value of VOLUME : " << (int)volume << endl;



//Third print the real value of volume with two digits after decimal

cout << "Real Value of VOLUME (upto 2 decimal) : " << setprecision(5) << volume << endl;

system("pause");
return 0;
}

Reply With Quote
Reply

Viewing: Tutorialized ForumsDesktop ProgrammingC and Cpp > I'm a Noob and need help with my homework


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap