0% found this document useful (0 votes)
58 views3 pages

Lab Task 2:: Apply Following formula's in your program b using (#define) - V=4/3πr^3

The document provides code for a C++ program that calculates volume using two formulas: V=4/3πr^3 for the volume of a sphere and V=πr^2h for the volume of a cylinder. The program defines π as 3.14, prompts the user to input radius and height values, displays the radius and height, calculates the volume using the appropriate formula, and outputs the result. The output includes the student name, student ID, and date.

Uploaded by

safia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views3 pages

Lab Task 2:: Apply Following formula's in your program b using (#define) - V=4/3πr^3

The document provides code for a C++ program that calculates volume using two formulas: V=4/3πr^3 for the volume of a sphere and V=πr^2h for the volume of a cylinder. The program defines π as 3.14, prompts the user to input radius and height values, displays the radius and height, calculates the volume using the appropriate formula, and outputs the result. The output includes the student name, student ID, and date.

Uploaded by

safia
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Computer Fundamentals

C++ Programming

[Type text]

LAB TASK 2:
Apply Following formula`s in your program b using
(#define).
i)

V=4/3r^3

ii)

V=r^2h

#include<iostream.h>
#include<conio.h>
#define p 3.14
void main(void)
{
clrscr();
int r,h ;
float vol;
cout<<"Enter Value of r ";
cin>>r;
cout<<"Enter Value of h ";
cin>>h;
clrscr();
cout<<Radius= <<r<<endl;
cout<<Height= <<h<<endl;
vol=4/3p*r*r*r;
cout<<"Volume of sphere "<<vol<<endl;
}
OUTPUT:

Safia Sohail

12-EE-109

14-02-2013

Computer Fundamentals

ii)

C++ Programming

[Type text]

V=r^2h
#include<iostream.h>
#include<conio.h>
#define p 3.14
void main(void)
{clrscr();
int r,h;
float volume;
cout<<"Enter Value of r ";
cin>>r;
cout<<"Enter Height h ";
cin>>h;
clrscr();
cout<<Radius= <<r<<endl;
cout<<Height= <<h<<endl;
volume=p*r*r*h;
cout<<"Volume= "<<volume<<endl;
}

OUTPUT:

Safia Sohail

12-EE-109

14-02-2013

Computer Fundamentals

Safia Sohail

C++ Programming

[Type text]

12-EE-109

14-02-2013

You might also like