Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Why does my code output in scientific notation program CalculateVolumes; #include ( stdlib . hhf ) ; static r: real 3 2 ;
Why does my code output in scientific notation
program CalculateVolumes;
#includestdlibhhf;
static
r: real;
h: real;
sphereVolume: real;
cylinderVolume: real;
coneVolume: real;
pi: real :; More accurate pi constant
begin CalculateVolumes;
stdout.putCalculating volumes of Sphere, Cylinder, and Cone", nl;
Collecting user input
stdout.putWhats your value of r: ;
stdin.getr;
stdout.putWhats your value of h: ;
stdin.geth;
Calculate volume of a sphere
fldr; Load radius
fldst; Duplicate radius r
fldst; Duplicate radius r
fmulpst st; r
fmulpst st; r
fldpi; Load pi
fmulpst st; pir
fld;
fld;
fld;
faddpst st;
faddpst st;
fdivp; pir
fld;
fld;
fld;
fld; Load
faddst st;
faddst st; Make it on stack
fmulpst st; pir
fstpsphereVolume; Store the result in sphereVolume
Calculate volume of a cylinder
fldpi; Load pi
fldr; Load radius
fldst; Duplicate radius r
fmulpst st; r
fldh; Load height
fmulpst st; r h
fstpcylinderVolume; Store the result in cylinderVolume
Calculate volume of a cone
fldcylinderVolume; Load volume of cylinder
fld;
fld;
fld; Load
faddst st;
faddst st; Make it on stack
fdivp; cylinderVolume
fstpconeVolume; Store the result in coneVolume
Output results
stdout.putYour sphere has volume sphereVolume, nl;
stdout.putYour cylinder has volume cylinderVolume, nl;
stdout.putYour cone has volume coneVolume, nl;
end CalculateVolumes;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started