a) const double Pi=3.14;
b) double Parameter;
c)cout<<"input data";
cin>>data;
d) int num_compt;
cout<<"input number of computer";
cin>>num_compt;
Exercise 2
a) 5 * 2 % 3 + 25 / 5
=10%3+25/5
= 1+5
= 6
b) a = 5, b = 6 !((a < a ="="> 9))
!((5 < 5 ="="> 9))
!(1 && 0 0 )
!(00)
!(0)
1
Exercise 3
main()
{
float allowance=300.00;
float salary;
cout<<"Input Salary=";
cin>>salary;
Tsalary=salary+ Allowance;
cout>>"Salary is=" , salary;
}
Exercise 4
#include
main()
{
double day_salary;
int days=20;
double monthly_salary;
cout<<"enter day salary";
cin>>day_salary;
cout<<"enter days working";
cin>>days;
monthly_salary=Day_salary*days;
cout<<"Your monthly salary =", monthly_salary;
}
Exercise 5
Program that calculates the average of 5 numbers that can be input by user.
#include iostream.h
main()
{
int num1, num2, num3, num4, num5, average;
cout<<"enter number 1";
cin>>num1;
cout<<"enter number 2";
cin>>num2;
cout<<"enter number 3";
cin>>num3;
cout<<"enter number 4";
cin>>num4;
cout<<"enter number 5";
cin>>num5;
average=(num1+num2+num3+num4+num5)/5;
cout<<"average for five number is=" , average;
}
Exercise 6
Program that will calculate the area of rectangular, triangle and circle.
#include iostream.h
main()
{
double area_rect , area_triangle, area_circle, base , height, width, radius;
const double =3.14;
cout<<"Calculate area of rectangular.";
cout<<"Enter height=";
cin>>height;
cout<<"Enter width";
cin>>width;
area_rect=height * width;
cout<<"area of rectangular=", area_rect;
cout<<"Calculate area of triangle.";
cout<<"Enter base=";
cin>>base;
cout<<"Enter height";
cin>>height;
area_triangle= 1/2 * base * height ;
cout<<"area of triangle=", area_triangle;
cout<<"Calculate area of circle.";
cout<<"Enter radius=";
cin>>radius;
area_circle= 3.14;
cout<<"area of circle=", area_circle;
}
(Weekly Reflection 2)
*Msuk kls mcm biase dan sign attendance.
*Miss bg rehat stngh jam dan msuk smula kls pd pkul 10.
*Bljr chapter 2.
*Miss bg exercise 2 tntg coding (buat dlm kmpuln).
*Buat weely reflection by group.
*Balik.