Followers

Tuesday, March 1, 2011

jawapan exercises 1 tu..

   1. Write correct C++ syntax & for each statement below:


a) Initializing variable Pi with the value 3.14 (constant)


 const double Pi = 3.14;


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<<"input data";
  cin>>data;

d) Input number of computer using variable (input assign to variable value

int num_compt;
cout<<"input number of computer";
cin>>num_compt;

2. Solve the question below. Show the working.

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

3) Identify syntax errors in the following program.

include<iostream.h>
main()
{
float allowance = 300.00, salary;

cout<<"Input Salary = ";
cin>>salary;

TSalary = salary + Allowance;

cout<<"Salary is= "<< salary;
}

answer:







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



#include<iostream.h>
main()
{
      float salaryperhour,monthlysalary;
      cout<<"enter salaryperhour=";
      cin>>salaryperhour;
      monthlysalary*salaryperhour;
      cout<<"monthlysalary"<<salaryperhour;
      return 0;
      }








5. Write a program that calculates the average of 5 numbers that can be input by user.

answer





#include<iostream.h>
main()
{
      int number1, number2, number3, number4, number5, average;
      cout<<"enter 5 numbers";
      cin>>number1;
      cin>>number2;
      cin>>number3;
      cin>>number4;
      cin>>number5;
      average= (number1+number2+number3+number4+number5)/5
      cout<<"total average="<<average;
      return 0;
      }





6. Write a program that will calculate the area of rectangular, triangle and circle.

answer

Rectangular





Triangle





Circle





finishhhh!!!!

No comments:

Post a Comment