0% found this document useful (0 votes)
30 views2 pages

Sample Output:: Laboratory Exercise 9 C++ Basic Programs

The document provides instructions for writing 5 basic C++ programs: 1) a program to calculate the sum of two numbers, 2) a program to determine the size of fundamental data types, 3) a program to convert temperature from Celsius to Fahrenheit, 4) a program to convert kilometers per hour to miles per hour, and 5) a program to calculate the total and average of 4 numbers. Sample outputs are provided for each program to demonstrate the expected output format and calculations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views2 pages

Sample Output:: Laboratory Exercise 9 C++ Basic Programs

The document provides instructions for writing 5 basic C++ programs: 1) a program to calculate the sum of two numbers, 2) a program to determine the size of fundamental data types, 3) a program to convert temperature from Celsius to Fahrenheit, 4) a program to convert kilometers per hour to miles per hour, and 5) a program to calculate the total and average of 4 numbers. Sample outputs are provided for each program to demonstrate the expected output format and calculations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Laboratory Exercise 9

C++ BASIC PROGRAMS

Objectives:

 Learn how print output in C++


 Learn how to take an input in C++
 Learn how to use basic arithmetic operation in C++

Instructions:

1. Write a program that prints the sum of two numbers.

Sample Output:

Enter a number: 29

Enter a number: 30

-----------------------------------

The sum of 29 and 30 is : 59

2. Write a program that finds Size of fundamental data types.

Sample Output:

Find Size of fundamental data types :

------------------------------------------

The size of(char) is : 1 bytes

The size of(short) is : 2 bytes

The size of(int) is : 4 bytes

The size of(long) is : 8 bytes

The size of(long long) is : 8 bytes

The size of(float) is : 4 bytes

The size of(double) is : 8 bytes

The size of(long double) is : 16 bytes

The size of(bool) is : 1 bytes.

3. Write a program that converts temperature in Celsius to Fahrenheit.

Use this formula: frh = (cel * 9.0) / 5.0 + 32

Sample Output:
Convert temperature in Celsius to Fahrenheit :

---------------------------------------------------

Input the temperature in Celsius : 35

The temperature in Celsius : 35

The temperature in Fahrenheit : 95

4. Write a program that converts kilometers per hour to miles per hour.

Use this formula: miph = (kmph * 0.6213712)

Sample Output:

Convert kilometers per hour to miles per hour :

----------------------------------------------------

Input the distance in kilometer : 25

The 25 Km./hr. means 15.5343 Miles/hr.

5. Write a program in that computes the total and average of four numbers.

Sample Output:

Compute the total and average of four numbers :

----------------------------------------------------

Input 1st two numbers (separated by space) : 25 20

Input last two numbers (separated by space) : 15 25

The total of four numbers is : 85

The average of four numbers is : 21.25

You might also like