6
QUESTION AREA & VOLUME #include <cstdlib> #include <iostream> using namespace std; int main(int argc, char *argv[]) { double Area,Volume; float r,h; cout<<"This program will calculate the area of a circle "<<endl; cout<<"and the volume of a cylinder"<<endl<<endl; cout<<"Please enter the radius of a circle"<<endl; cin>>r; cout<<endl; cout<<"Please enter the height of a cylinder"<<endl; cin>>h; Area=3.142*r*r; Volume=3.142*r*r*h; cout<<"Area of the circle is "<<Area<<endl; cout<<"Volume of the cylinder is "<<Volume<<endl; system("PAUSE"); return EXIT_SUCCESS; } Pseoducode : Start Insert r and h Area= 3.142 x r x r Volume= 3.142 x r x r x h Print Area and volume End

Assignment csc

Embed Size (px)

DESCRIPTION

csc

Citation preview

Page 1: Assignment csc

QUESTION AREA & VOLUME

#include <cstdlib>

#include <iostream>

using namespace std;

int main(int argc, char *argv[])

{

double Area,Volume;

float r,h;

cout<<"This program will calculate the area of a circle "<<endl;

cout<<"and the volume of a cylinder"<<endl<<endl;

cout<<"Please enter the radius of a circle"<<endl;

cin>>r;

cout<<endl;

cout<<"Please enter the height of a cylinder"<<endl;

cin>>h;

Area=3.142*r*r;

Volume=3.142*r*r*h;

cout<<"Area of the circle is "<<Area<<endl;

cout<<"Volume of the cylinder is "<<Volume<<endl;

system("PAUSE");

return EXIT_SUCCESS;

}

Pseoducode :

Start

Insert r and h

Area= 3.142 x r x r

Volume= 3.142 x r x r x h

Print Area and volume

End

Page 2: Assignment csc
Page 3: Assignment csc

QUESTION 6-TUTORIAL 2

Page 4: Assignment csc

TUTORIAL 2- QUESTION 12

#include <cstdlib>

#include <iostream>

using namespace std;

int main(int argc, char *argv[])

{

int x,y,Total;

cout<<"Please enter no of adult : ";

cin>>x;

cout<<"Please enter no of teenager : ";

cin>>y;

Total=(x*23)+(y*14);

cout<<"The total payment is RM : "<<Total<<endl;

system("PAUSE");

return EXIT_SUCCESS;

}

Page 5: Assignment csc