0% found this document useful (0 votes)
22 views3 pages

Lab C++

The document contains code for calculating averages of integer and double numbers. In exercise 3, it defines integer variables num1, num2, num3 and average, assigns values to num1, num2, num3, calculates the average and prints the values and average. Exercise 4 repeats this for double type variables, assigning decimal values to num1, num2, num3, calculating average and printing results.

Uploaded by

Siti Nadiah
Copyright
© Attribution Non-Commercial (BY-NC)
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)
22 views3 pages

Lab C++

The document contains code for calculating averages of integer and double numbers. In exercise 3, it defines integer variables num1, num2, num3 and average, assigns values to num1, num2, num3, calculates the average and prints the values and average. Exercise 4 repeats this for double type variables, assigning decimal values to num1, num2, num3, calculating average and printing results.

Uploaded by

Siti Nadiah
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 3

Answers For Lab1 Exercises Question 3 a. #include<iostream> b. using namespace std; c.

int int int int OR int num1, num2, num3,average; d. num1 = 25; num2 = 128; num3=-25; e. average = (num1+num2+num3)/3; f. cout<< Value of num1= << num1 <<endl; cout<< Value of num2= << num2 <<endl; cout<< Value of num3= << num3 <<endl; cout<< Average of the 3 numbers= << average <<endl; g. Output: Value of num1= Value of num2= Value of num3= Average of the 25 128 -25 3 numbers= 42 num1; num2; num3; average;

Questions 4 (Repeat Exercise 3) a. #include<iostream> b. using namespace std; c. double double double double OR double num1, num2, num3,average; d. num1 = 75.35; num2 = -35.56; num3=15.76; e. average = (num1+num2+num3)/3; f. cout<< Value of num1= << num1 <<endl; cout<< Value of num2= << num2 <<endl; cout<< Value of num3= << num3 <<endl; cout<< Average of the 3 numbers= << average <<endl; Output: Value of num1= Value of num2= Value of num3= Average of the num1; num2; num3; average;

75.35 -35.56 15.76 3 numbers= [answer]

Question 5

#include<iostream> using namespace std; int main(){ intlength; int width; int area; int perimeter; cout<< Enter the length: ; cout<<endl; cin>> length; cout<<Enter the width:; cout<<endl; cin>>width; area = length * width; cout<<Area = << area <<endl; cout<<Perimeter<<perimeter<<endl; }

You might also like