FINAL EXAMINATION
Format: Font Size=8, Font Face=Arial, Single Space
Name: DUMALAG JOSHUA D SECTION: 1-BSCS-3
Select the machine problem with corresponding score. If the chosen machine problem having syntax or
logical errors the score is automatically ZERO. Passing Score 70/100
GRADE PROBLEM
25 Write a program that asked the user to input height in inches and then display the height in
centimeter. (1inch = 2.54centimeter)
CODE OUTPUT (SCREENSHOT)
#include <iostream>
using namespace std;
int main()
{
float a=2.54,num1,value;
cout<<"Input Height: ";
cin>>num1;
num1= num1* 2.54 ;
value= num1;
cout<<value;
return 0;
}
25 2. Program prompts the user to input the height and the radius
of the base of a cylinder and outputs the volume and surface
area of the cylinder
VOLUME = PI * radius2 * height
SURFACE AREA: =2 * radius * 2 * PI * radius2
CODE OUTPUT (SCREENSHOT)
#include <iostream>
#include<iomanip>
using namespace std;
int main()
{
float radius, volume, surface,pi=3.14159,height;
cout<<"Enter radius :";
cin>>radius;
cout<<"Enter height :";
cin>>height;
volume = pi * (radius*radius) * height;
surface= 2 * radius * 2 * pi * (radius*radius);
cout<<volume;
cout<<endl;
cout<<surface;
return 0;
}
25 3. Write a program that prompts the user to enter the weight of
a person in kilograms and outputs the equivalent weight in
pounds. Output both the weights rounded to two decimal
places.
CODE OUTPUT (SCREENSHOT)
#include <iostream>
using namespace std;
int main()
{
float weight, kilo,pounds=2.2;
cout<<"Enter Weight in kilogram: ";
cin>>kilo;
pounds=kilo*2.20462;
cout<<"Weight in kilogram: ";
cout<<kilo;
cout<<"\nWeight in pounds: ";
cout<<pounds;
return 0;
}
50 3. Write a program to read in numbers until the number -999 is encountered. The sum of
all number read until this point should be printed out. (USING WHILE STATEMENT)
CODE OUTPUT (SCREENSHOT)
#include <iostream>
using namespace std;
int main()
{
float input;
float sum =0;
input =0;
while(input !=(-999))
{
cout<<"Please Enter number: ";
cin>>input;
sum+= input;
if(input== (-999))
{
sum = sum+ 999;
}
else
continue;
}
cout<<"Sum of entered number : ";
cout<<sum;