0% found this document useful (0 votes)
5 views

C++ Assignment

The program takes in a time value in hours and converts it to minutes and seconds by multiplying and dividing the hours value by 60 and 3600 respectively. It declares the variables to store hours, minutes, seconds values, assigns the hours value, calculates minutes and seconds, and prints the output.

Uploaded by

Naila Mehr
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

C++ Assignment

The program takes in a time value in hours and converts it to minutes and seconds by multiplying and dividing the hours value by 60 and 3600 respectively. It declares the variables to store hours, minutes, seconds values, assigns the hours value, calculates minutes and seconds, and prints the output.

Uploaded by

Naila Mehr
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

“Write a program to calculate area and volume of a

sphere”
#include<iostream.h>

main()

float radius,area,volume;

float PI=3.14;

cout<<“Enter radius of the sphere”;

cout<<endl;

cin<<radius;

area=4*PI*radius*radius

volume= (4/3)*PI*radius*radius*radius;

cout<<“Volume of sphere is equal to:”,volume;

cout<<endl;

cout<<“Area of a sphere is equal to:”,area;

}
Start

Declare variables
Radius, area and
Volume

Give a value of constant


PI=3.14

Get value of radius

Compute area by A=π r 2


And volume by
V=4/3 π rᶟ

Print “Volume of sphere is


equal to”
Print “Area of sphere is
equal to”

End
Algorithm

> start

> declare variables radius area and volume

> use value of constant PI=3.14

> enter radius of the sphere

> get value of radius from user

> compute area of sphere by using formula ( A=4 π r 2)

> compute volume of sphere by using formula (4/3 π rᶟ)

> print “volume of sphere is equal to”

> print “Area of sphere is equal to”

> end of program


“Write a program in C++ to convert temperature
(Fahrenheit) into Celsius Degree scale”
#include<iostream.h>

main()

float celsius_temp,fahrenheit_temp;

cout<<“Enter temp in Fahrenheit”<<endl;

cin<<fahrenheit_temp;

celsius _temp=5/9(Fahrenheit_temp-32);

cout<<”Temperature in celsius is=”,celsius_temp;

}
Algorithm

> start

> declare 2 variable celsius_temp, fahrenheit_temp

> get value of temperature in Fahrenheit from user

> compute temperature in celsius by using formula [5/9(f-32)]

> print “Temperature in Celsius is =”

> end of program

Start

Declare 2 variables
float celsius_temp
And fahrenheit_temp

Get value of temperature


in Fahrenheit from user

Compute temperature by
using formula C=5/9(f-32)

Print
“Temperature in
celsius is=”

End
“Write a program to convert value of variable time
(hours) t=2.36 hours into minutes and seconds”
#include<iostream.h>

#include<conio.h>

#include<stdio.h>

main()

float t, sec,min,hr;

t=2.36;

min=60/t;

sec=60*60/t;

cout<<“Time in minutes”,minutes<<endl;

cout<<“Time in seconds”,sec;

}
Algorithm
> Start

> declare 4 variables t, sec ,min and hr

> put t=2.36

> multiply 60 by t to get minutes

> multiply minutes by 3600 to get seconds

> print “Time in minutes”

> print “Time in seconds”

> end of program

Start

Float t, sec,
min, hr

Put t=2.36

Multiply 60 by t to get
minutes
Multiply min by 3600 to
get seconds

Print “Time in minutes”


Print “Time in seconds”

End

You might also like