a) Initializing variable Pi with the value 3.14 (constant)
answer :
float pi =3.142;
b) Declare a variable named Perimeter with double data type (declare variable)
answer :
double perimeter
c) Give instruction that allowed user to input data (input)
answer :
int data;
//input
cout<<"enter your data";
cin>>data;
d) Input number of computer using variable (input assign to variable value)
answer :
int number;
cin>>number;
2. Solve the question below. Show the working.
a) 5 * 2 % 3 + 25 / 5
answer :
= [10%3]+25/5
= 1+[25/5]
= 1+5
= 6
b) a = 5, b = 6
!((a < 3) && (a == 3) || (b > 9))
answer :
= !((5<3)&&(5 == 3) || (6>9))
= !((0) &&(0) || (0)
= !((0) (0)
= !(0)
= 1
3. Identify syntax errors in the following program. (5errors)
include<iostream.h>
main()
{
float allowance = 300.00, salary;
cout<<"Input Salary = ";
cin>>salary;
TSalary = salary + Allowance;
cout<<"Salary is= "<< salary;
}
answer :
#include<iostream.h>
main()
{
float allowance = 300.00, salary;
cout<<"Input Salary = ";
cin>>salary;
TSalary = salary + Allowance;
cout<<"Total Salary is= "<< Tsalary;
return 0;}
4. Write a program that will calculate the monthly salary for an employee that where Saturday and Sunday are considered as non-working days.
answer :
5. Write a program that calculates the average of 5 numbers that can be input by user.
answer :
6. Write a program that will calculate the area of rectangular, triangle and circle.
answer :
No comments:
Post a Comment