Lab Task 2:: Apply Following formula's in your program b using (#define) - V=4/3πr^3
Lab Task 2:: Apply Following formula's in your program b using (#define) - V=4/3πr^3
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