Wednesday, April 6, 2011

CORRECTIONS FOR F.O.P MIDTERM EXAM JANUARY 2011 - QUESTION 2

QUESTION 2

if ... else statement

1.








2.








3.














switch.. case statement

1.













2.













Tuesday, April 5, 2011

CORRECTIONS FOR F.O.P MIDTERM EXAM JANUARY 2011 - QUESTION 1: SECTION B


QUESTION 1: SECTION B


Variables

A variable is the storage location in memory that is stored by its value. A variable is identified or denoted by a variable name. The variable name is a sequence of one or more letters, digits or underscore.

For example: character _


Rules for defining variable name:

  1. Variable's name MUST be unique.
  2. Cannot be more than 31 characters.
  3. MUST begin with letters.
  4. NO space in between.
  5. Can't begin with numbers, symbols, or special characters.


DATA TYPES

  1. CHARACTER
  • Consist of all LETTERS, NUMBERS, and SPECIAL SYMBOLS.
  • Surrounded by SINGLE QUOTATION MARK (' ' ).
  • Example: 'A', 'm', '#', '1', or ' '.



  1. STRING
  • Combination of more than one character.
  • Surrounded by DOUBLE QUOTATION MARK (" " ).
  • Example: (" WELCOME TO MY PAGE") OR ("8876").


  1. LOGICAL VALUES/BOOLEAN
  • Making Yes-or-No decisions ( TRUE-or-FALSE).
  • Example: to check two integers using if… … else control structure.

    Assume a=2 and b=5

    If (a<b)


    Decision is TRUE

    Else

    Decision is FALSE



  1. INTEGER
  • Whole POSITIVE and NEGATIVE numbers including ZERO and NO DECIMAL place.
  • Example: 0, +1, -10.
  • Used to represent the counting of things.
  • Example: Numbers of month in a year (1,2,3 …).



  1. FLOATING POINTS (FLOAT)
  • Contain all numbers with DECIMAL points.
  • Stored in floating point
  • Used for metric measurement, temperature and price.
  • Example: 1.0cm, 234.55kg, RM20.30, 36.7C.



  1. DOUBLE
  • Floating point data types comes in three sizes, namely float, double and long double.
  • The difference is in the length of value and amount of precision which they can take and it increases from float to long double.
  • double: This data type is used to represent double precision floating point number.




  1. LONG DOUBLE
  • This data type is used to represent double precision floating point number.



  1. CONSTANT
  • fixed values which cannot change.
  • example 123, 12.23, 'a' are constants.



  1. ARRAY
  • A set of locations in the computer memory that has the same name and contains the same data type.
  • It is almost the same as variable, but variable has allocated only one location that can store one value at a time. Where else, array can allocate more than one location to store several values at a time.



  1. LONG/SHORT INTEGER
  • LONG INTEGER: This data type is used to represent long integer.
  • SHORT INTEGER: This data type is used to represent short integer.

CORRECTIONS FOR F.O.P MIDTERM EXAM JANUARY 2011 - QUESTION 1

QUESTION 1


1.








2.










ANSWER

  1. iostream.h
  2. int
  3. for
  4. i
  5. i++
  6. i
  7. price
  8. total
  9. price
  10. total

Wednesday, March 30, 2011

FOP

Ja tolka xo4y ckazat eclu ja magy exat b ykrainy.

trudHo mhe zdec *ut!!!!!!!!!!!!!!!!!

ASSIGNMENT 2









step by step


1.














2.













3.














4.












5.

ASSIGNMENT 1

WRITE A PROGRAM








**********************

MESIN TIN MINUMAN

-------------------------


JENIS RM

-------------------------

1. PEPSI 1.80

2. COCA COLA 1.90

3. F&N ORANGE 1.50

4. F&N MIRINDA 1.60

5. 100 PLUS 2.00

**********************


Your selection:

Insert your money:


*Your balance are _________

* Please insert _______ Your money is not enough!!: _________


Thank you!

Please come again!


__________________________________________________________________


STEP BY STEP:

1.












2.













3.























5.













6.











7.



















8.










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 **