atas sebab-sebab tertentu yg agak payah untuk dijelaskan....
terpaksa la post assignment yang miss bagi dgn meng-sharing file tersebut....
nanti aq post sepenuhnya bila da kewangan aq stabil....or plg lmbt ari isnin yg terdekat
[EDIT]
Da ble post
1. Write correct C++ syntax & for each statement below:
a) Initializing variable Pi with the value 3.14 (constant)
a) Initializing variable Pi with the value 3.14 (constant)
Const float Pi=3.142;
b) Declare a variable named Parameter with double data type (declare variable)
Double parameter
c) Give instruction that allowed user to input data (input)
Cout<<”please insert your score”;
d) Input number of computer using variable (input assign to variable value)
//variable nc=number of computer
Int nc;
//input
Cout<<”Insert number of computer:”;
Cin>>nc;
b) a = 5, b = 6
!((a < 3) && (a == 3) || (b > 9))
1. Solve the question below.
Show the working.
a) 5 * 2 % 3 + 25 / 5
a) 5 * 2 % 3 + 25 / 5
[(5*2)%3] + [25/5]
[(10)%3] + [5]
[1] + [5]
6
b) a = 5, b = 6
!((a < 3) && (a == 3) || (b > 9))
NOT[(5<3:0)&&(5==3:0) || (6>9:0)]
NOT[(0&&0)
|| 0]
NOT[0 || 0]
NOT[0]
1
2. Identify syntax errors in
the following program.
#include<iostream.h>
main()
{
float allowance = 300.00, salary, TSalary;
cout<<"Input Salary = ";
cin>>salary;
TSalary = salary + allowance;
cout<<"Salary is= "<< salary;
#include<iostream.h>
main()
{
float allowance = 300.00, salary, TSalary;
cout<<"Input Salary = ";
cin>>salary;
TSalary = salary + allowance;
cout<<"Salary is= "<< salary;
return 0;
}
}
3. Write a program that will
calculate the monthly salary for an employee that where Saturday and Sunday are
considered as non-working days.
#include
<iostream.h>
main()
{
//declare
float
allowance=500.00,salary=40,tsalary,day;
//input
cout<<"please input total days
work";
cin>>day;
//process
tsalary = (salary*day)+allowance;
//output
cout<<"The total salary for
this month is:RM "<<tsalary;
return 0;
}
4. Write a program that
calculates the average of 5 numbers that can be input by user.
#include<iostream.h>
main()
{
//declare
variable
float a,b,c,d,e,average;
//input
cout<<”please
insert 5 numbers here: \nExample: a,b,c,d,e”<<endl;
cin>>a,
b, c, d, e;
//process
average =
(a+b+c+d+e)/5;
//output
cout<<”The
average is:”<<average;
return 0;
}
5.
Write a program that will calculate the area of rectangular,
triangle and circle.
#include
<iostream.h>
main()
{
//declare
float b,h,r,w,area,;
float pi=3.14;
int selection;
//out
cout<<"Please choose you
choice"<<endl;
cout<<"1.Rectangular";
cout<<"\n2.Triangle";
cout<<"\n3.Circle"<<endl;
cin>>selection;
switch (selection)
{
case 1: cout<<"Please
input the height"<<endl;
cin>>h;
cout<<"Please
input the width"<<endl;
cin>>w;
//process
area = w*h;
cout<<"The area
is:"<<area;
break;
case 2: cout<<"Please
input the height"<<endl;
cin>>h;
cout<<"Please
input the base"<<endl;
cin>>b;
//process
area = 0.5*b*h;
cout<<"The area
is:"<<area;
break;
case 3: cout<<"Please
input the radius"<<endl;
cin>>r;
//process
area = pi*r*r;
cout<<"The area
is:"<<area;
break;
default :cout<<"Invalid
Selection";
return 0;
}
}
No comments:
Post a Comment