Monday, February 28, 2011

EXERCISES (DO IN YOUR BLOG)

22  FEBRUARY 2011 

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


a) Initializing variable Pi with the 3.14 (Constant)
     Variable name =
      Float Pi = “3.14” ;

b) Declare a variable names Parameter with double data type  ( declare variable )
     Double data Parameter ;

c) Give instruction that allowed user to input data ( input )
     int  data ;
     cout <<  “Enter the data “ ;
     cin >> data ;

d) Input number of computer using variable ( input assign to variable value )
    int number ;
    cin >> data ;

 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 < 3 ) && ( a= = 3 ) || ( b > 9 )
         = !((5 < 3) && ( 5 == 3 ) ||  ( 6 > 9 )
         = !((  0 && 0 ) || ( 0 ))
         = !(( 0 || 0 ))
         = ! ( 0 )
         =   1


3)  Identify syntax errors in the following program.
  
     #include<iostream.h>
      main ()

      {

      float allowance = RM 300.00 salary, Tsalary ;
         
      cout << “input salary =  “ ;
      cin >> salary ;

      T salary = salary + Allowance ;

      Cout << “ Total salary  is  =   “ << salary ;
     
      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.



5. Write a program that calculate the average of 5 number that can be input by user.
    
   

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

Triangle


Circle


Rectangular





 


     

No comments:

Post a Comment