BLOGGER TEMPLATES AND TWITTER BACKGROUNDS »

Saturday, March 5, 2011

EXECISE 23 FEB 2011

1) SOLVE THE QUESTION BELOW

a) 5 * 2 % 3 + 25 / 5
    10     % 3 + 5
    1              + 5
    6 (answer)

b)  a=5 , b=6
  
    ! ( ( a <  3 ) && ( a = = 3 ) II ( b > 9 ) )
    ! ( ( 5 <  3 ) && ( 5 = = 3 ) II ( 6 > 9 ) )
    ! ( (    0    ) &&  (  0   )      II (   0     ) )
    ! ( 0 )           =       1   II TRUE


2 ) Identify the syntax errors in the following program

# include < iostream.h>
mai ( )
{
float allowance = 300.00 salary ;
// input
cout  << " input salary = '' ;
cin > salary ;
salary = salary + allowance ;
// output
cout << '' salary is = '' << salary;
}

answer :
# include < iostream.h >
main ( )
{
float allowance = 300.00 salary ;
// input
cout  << " input salary = '' ;
cin >> salary ;
salary = salary + allowance ;
// output

cout << '' salary is = '' << salary ;
return 0 ;

}

3. write a program that calculate the monthly salary for an employee that where saturday & sunday are considered as non working days

# include < iostream.h >
main ( )
// declare variable
float no working days ;
float salary per day ;
float monthly salary ;
// input 1
cout << '' enter no working days '' ;
cin >> '' no working days '' ;
// input 2
cout << '' enter salary per day '' ;
cin >> '' salary per day '' ;
// formula
'' monthly salary = working days * salary per day '' ;
// output
cout << '' monthly salary << monthly salary '' ;
return 0 ;
}

4) write a program that calculates the average of 5 numbers that can be input by user

# include < iostream.h >
main  ( )
float no 1
float no 2
float no 3
float no 4
float no 5
float total
float average
// input
cout << '' num 1 '' ;
cin >> '' num 1 '' ;
cout << '' num 2 '' ;
cin >> '' num 2 '' ;
cout << '' num 3 '' ;
cin  >> num 3 '' ;
cout << '' num 4 '' ;
cin >> '' num 4 '' ;
cout << '' num 5 '' ;
cin >> '' num 5 '' ;
// formula
total = num1 + num2 + num3 + num4 + num5
// output 1
cout << '' total / 5 '' ;
//output 2
cout << '' average '' << average ;
return 0 ;
}

5 ) write  program that will calculate the area of rectangular , triangle , circle


# include < iostream.h >
main ( )
{
declare variable
float height ;
float width ;
float area_rectangle ;
float radius ;
float area_circle ;
float height ;
float area_triangle ;
// input 1
cout << '' enter height '' ;
cin >> '' height '' ;
// input 2
cout << '' enter width '' ;
cin >> '' width '' ;
// input 3
cout << '' enter radius '' ;
cin >> '' radius '' ;
// formula 1
area_rectangle = height*width ;
//output 1
cout << '' area_rectangle = '' << area_rectangle ;
// formula 2
area_circle = 3.14*radius*radius ;
//output2
cout << '' area_circle = '' << area circle ;
// formula3
area_triangle = 0.5*height*height ;
//output3
cout << '' area_triangle = '' area_triangle ;
retrun o ;
}

MATA DAH NGANTOK , SAMBUNG ESOK LA JWBNYERR

0 comments: