Wednesday, March 2, 2011

Fundamental of Programming - 23rd Feb 2011

It's CHINGAY today!

All main roads closed!
* Sorry Ms. Ayuni that I've to bunk class today * ^_^
Yet it never stopped me from blogging on FOP classes.

Well said..
Since many of my classmates did not make it to class, Ms. Ayuni decided to give us 5 questions.
* TQ RITA for giving me the questions on Friday! At least I'm not a lost case! haha *



QUESTION 1.

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

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

QUESTION 2
Identify the syntax errors in the following program:

include
mai ()
{
float allowance=300.00,salary;
cout<<"Input salary="; cin>salary;
Tsalary=salary+allowance;
cout<<"salary is="<>
4.Tsalary
5. return 0;

#include//header
main()//start body
{//open curly bracket
float allowance=300.00,salary;
cout<<"Input salary=";
cin>>salary;
salary=salary+allowance;
cout<<"salary is="<return 0;
}//close curly bracket
//end body


QUESTION 3
Write a program that will calculate the salary for an employee that where Saturday and Sunday are considered as non-working days.

#include
main()
{
//decalre variable
float no_working_days;
float salary_per_day;
float monthly_salary;
//input 1
cout<<"no_working_days";
cin>>no_working_days;
//input 2
cout<<"salary_per_day";
cin>>salary_per_day;
//formula
monthly_salary=no_working_days*salary_per_day;
//output
cout<<"monthly_salary"<return 0;
}//close curly bracket
//end body


QUESTION 4
Calculate the average of 5 numbers.

#include//header
main()//start body
{//open curly bracket
//declare variable
float num1;
float num2;
float num3;
float num4;
float num5;
float total;
float average;
//input 1
cout<<"num1";
cin>>num1;
//input 2
cout<<"num2";
cin>>num2;
//input 3
cout<<"num3";
cin>>num3;
//input 4
cout<<"num4";
cin>>num4;
//input 5
cout<<"num5";
cin>>num5;
//formula 1
total=num1+num2+num3+num4+num5;
//output 1
cout<<"total"<//formula 2
average=total/5;
//output 2
cout<<"average"<return 0;
}//close curly bracket
//end body



QUESTION 5

calculate area of rectnagle, circle and traingle.

#include
main()
{
//declare variable
float height;
float width;
float area_rectangle;
float radius;
float area_circle;
float area_triangle;
//input 1
cout<<"enter height";
cin>>height;
//input 2
cout<<"enter width";
cin>>width;
//input 3
cout<<"radius";
cin>>radius;
//formula 1
area_rectangle=height*width;
//output 1
cout<<"area_rectangle="<//formula 2
area_circle=3.14*radius*radius;
//output 2
cout<<"area_circle="<//formula 3
area_triangle=0.5*height*height;
//output 3
cout<<"area_triangle="<return 0;
}//close curly bracket
//end bosy


** will update the step by step soon .... this is for my eyes only. =) hehe **


No comments:

Post a Comment