skip to main | skip to sidebar

FUNDAMENTAL OF PROGRAMMING

Monday, March 28, 2011

ASSIGNMENT 2

STEP 1
STEP2
STEP3
STEP4
STEP 5
STEP 6
STEP7
STEP8CLICK RUN

coret curhat karra mc'yudied at 7:42 PM 0 comments

Sunday, March 27, 2011

CORDING ASSIGNMENT 1

STEP 1
STEP 2
STEP 3
STEP 4
STEP5

STEP 6

STEP 7

STEP 8

STEP 9

STEP 10
STEP 11

STEP 12

STEP 13

STEP 14

STEP 15
coret curhat karra mc'yudied at 7:56 PM 0 comments

ASSIGNMENT 1

write as 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 !!!!!! :________________
coret curhat karra mc'yudied at 7:34 PM 0 comments

Saturday, March 26, 2011

EXERCISE 2

QUESTION 1:
a) intializing variable pi with the value 3.14
ans: float pi = 3.14
b) Declare a variable named parameter with double data type
ans: Double perimeter;
c) Give instruction that allowed user to input data
ans: cout<< "enter your data";
cin>> data;
d) Input number of computer using variable
ans:cout<<"enter number";
cin>>number;


QUESTION 2:
Change the if....else statement below to switch....case statement
#include
main ()
{
int selection,quantity;
float price;
cout<<"1.pen = Rm0.50";
cout<<"2.pencil = Rm0.30";
cout<<"3.ruler = Rm0.20";
cout<<"4.eraser = Rm0.10";
cin>>selection;
cin>>quantity;
if (selection = =1)
{ price = quantity * 0.50;}
else if (selection = =2)
{ price = quantity * 0.30;}
else if (selection = =3)
{ price = quantity * 0.20;}
else if (selection = = 4)
{ price = quantity * 0.10;}
else
{ cout <<"invalid selection";}
cout<<"the price is : "<

#include
main ()
{
int selection,quantity;
float price;
cout<<"1.pen = Rm0.50";
cout<<"2.pencil = Rm0.30";
cout<<"3.ruler = Rm0.20";
cout<<"4.eraser = Rm0.10";
cin>>selection;
cin>>quantity;
switch (selection)
{
case 1: price = quantity * 0.50;break
case 2: price = quantity * 0.30;break
case 3: price = quantity * 0.20;break
case 4: price = quantity * 0.10;break
default: cout<<"invalid selection";
}
cout<<"the price is: "<
return 0;
}
coret curhat karra mc'yudied at 7:44 PM 0 comments

EXERCISE exam

QUESTION 1
change the if....else statements below to switch.....case statements:
#include
main()
{
int nom A,nom B,Selection,Value;
cout<<"enter 2 numbers:";
cin>>nomA >>nomB;
cout<<"1.addition";
cout<"2.subtraction";
cout<<"3.multiply";
cout<<"4.division";
cin>>selection;
{
if (selection ==1)
{value =nomA + nomB;}
else if (selection ==2)
{value =nomA - nomB;}
else if (selection ==3)
{value =nomA * nomB;}
else if (selection ==4)
{value =nomA / nomB}
else
cout<<"invalid selection";}
<<"the value is:"<

ANSWER:

#include
main()
{
int nom A,nom B,Selection,Value;
cout<<"enter 2 numbers:";
cin>>nomA >>nomB;
cout<<"1.addition";
cout<"2.subtraction";
cout<<"3.multiply";
cout<<"4.division";
cin>>selection;
switch (selection)
{case 1:value=nomA + nomB;break
case 2:value=nomA - nomB;break
case 3:value=nomA * nomB;break
case 4:value=nomA / nomB;break
default cout<<"invalid selection";
cout <<"the value is"<
}
return 0;
}
QUESTION 2
change for loop statement below to while loop.
#include
main()
{
int i,power 2;
for (i=1;i<=9;i++)
{
power 2= i * i;
cout<<" "<
}
}
ANSWER
#include
main()
{
int i,power 2;
while
i = 1;
while ( i <=9 )
{
power 2 = i * i;
cout <<" "<< i << "power 2" << power 2;
i++;
}
}
QUESTION 3
write a program that input 2 numbers.compare and display only the biggest number.if the numbers are same,display the numbers are same
ANSWER
#include
main()
{
int num1,num2;
cout<<"enter 2 numbers:";
cin >> nomA >> nomB;
//if...else statement
if (num 2 > num 1)
{ cout <<"num 2 is bigger than num 1";}
else if (num 2 == num 1)
{ cout <<"num 2 is same as num 1";}
else
{ cout <<"invalid selection";}
return 0;
}

QUESTION 4
write a programming using for loop that recive pricess of 3 products.calculate the price that must be paid after 10% discount is given to every customer.
ANSWER
#include
main()
{
int x,price,total discount;
for (x=1;x<4;x++)
{
cout<<"price [ "<< x << " ] : ";
cin>>price;
}
total + price;
}
cout<<"total = " << total;
discount = total * 0.01;
cout<<"discount = "<
return 0;
}

QUESTION 5
what is the output for the following program segment
I) int x=20;
for (int i=5;i<=x;i++)
{
cout <<1;
i = 1 + 4;
}
ANSWER:
5
10
15
20

II) Int mul = 1;
do
{
mul = mul * 2;
cout <<"the mul is :"<
mul+++;
}
while (mul<10)
ANSWER
1
3
7
coret curhat karra mc'yudied at 7:06 PM 0 comments

Friday, March 25, 2011

LOOP AND WHILE

LOOP
#include
main()
{
//declare variable
//get input
cout <<"enter an integer = ";
cin >> x;
//loop for
for (y=0;yWHILE
#include
main()
int x.y;
cout<<"enter an integer =";
cin>>x;
//while
y=1;
while (y
coret curhat karra mc'yudied at 7:33 PM 0 comments

Saturday, March 19, 2011

IF ELSE TO SWITCH CASE



if,,,else or switch case,,,depends on question

If else statement

#include
main ()
{
declare variable
int age;
//input
cout<<"enter your age =";
cin>>age;
//if..else statements
{ cout <<"your are child !";}
else if (age > = 7 ll age < = 12)
{ cout <<"you are teenager !";}
else if (age > = 22 ll age < = 30)
{cout <<"you are adult now!!";}
else if (age >30)
{ cout <<"you are old booooo.....";}
else
{cout<<"invalid selection";}
return o;
}

SWITCH CASE

#include
main ()
{
declare variable
int age;
//input
cout<<"enter your age =";
cin>>age;
switch..case statements
switch (age)
{ case ('age'> =1 ll age <= 6):cout<<"you are kids!";break;
case ('age'>=13 ll 'age' <= 12):cout<<"you are adult!";break;
case ('age'>=13 ll 'age'<=21):cout<<"you are teenager!";break;
case ('age'>= 22: ll 'age' <=30):cout<<"you are adult now!!";break;
case ('age'>=30):cout<<"you are old booooo.....";break;
default: cout<<"invalid selection";
}
return 0;
}
coret curhat karra mc'yudied at 7:35 PM 0 comments

Thursday, February 17, 2011

CHAPTER THREE

SAMPLE QUESTION GIVEN BY LECTURER

bm =
bi =
math=
sains =
total =
average =
formula
total = bm + bi + math + sains
average = total / 4
coret curhat karra mc'yudied at 3:16 AM 0 comments

Tuesday, February 15, 2011

CHAPTER THREE programming

1. Go to my Computer at desktop.


2. Go to Local Disc C.


3. Click at TC's file show.


4. Click at BIN.


5. Click at TC's application.


6. Click NEW.


7. Type data ( quesion given before ).


8. After done insert data, click COMPILE.


10. Click RUN .


11. After all process insert data, compile, run done..users may insert any data (eg: number as picture show).

coret curhat karra mc'yudied at 3:17 AM 0 comments

EXERCISE C1 & C2


Add and minus two INTEGER numbers with using the formula below:


add= num1+num2
minus= num2-num1


ANSWER

# include <> #header
main ( )
{
// variable declaration
int num 1,num 2,add,minus ;
// input 1
Cout << " enter num 1 : " ;
Cin >> num 1 ;
// input 2
Cout << " enter num 2 : " ;
Cin >> num 2 ;
// formula
add = num 1 + num 2 ;
// output
Cout << add =" <<">
// formula
minus = num 2 - num 1 ;
// output
Cout << " minus = <<
minus ;
return 0 ;
}
coret curhat karra mc'yudied at 3:12 AM 0 comments

Wednesday, February 9, 2011

CHAPTER TWO example 1


#include //header
Main( ) //start body
{ // Open curly braket
//declare variable
Float area;
Float radius;
// input 1
Cout <<“enter radius”;
Cin>> radius;
//formula
area = 3.14 *radius*radius
//output
Cout <<“answer”<
Return 0 ;
} // close curly bracket
//end bracket



coret curhat karra mc'yudied at 2:53 AM 0 comments

CHAPTER TWO

#include //header
Main ( ) // start body
{ // Open curly bracket
} // close curly bracket
// comment hidden
// 1 line coding
/ * , * / all coding @ more than 1 coding

Declare variable
Data_type variable_name

Data type
Int
Integer

Float
Float
Decimal
Double
Double
Decimal
Char
Character
a-z /A-Z
String
String
Sentences
Const
Constant
Tak berubah

Rules:
1. 1. Look and aware of formula
2.Find how many variable name
3.Declare variable

Input:
Cout <<“----------------------” ;
Cin >>variable_name_that_had_declared;
Rules: carefull with spelling,alphabet small and big
Output:
Cout <<“----------------------”<<
variable_name_that_had_declared;
coret curhat karra mc'yudied at 2:45 AM 0 comments

Monday, February 7, 2011

CHAPTER ONE example 3


example 3:
find the area of fahrenheit
fahrenheit =( 9/5 *( celcius + 32 ) )


Algorithm

1.get the celcius of fahrenheit
2.calculate fahrenheit equal nine devide by five multiply celcius plus 32
3.display fahrenheit

Pseudocode

1.read celcius
2.set the fohrenheit ( 9/5 *( celcius + 32 ) )
3.print output
coret curhat karra mc'yudied at 2:37 AM 0 comments

CHAPTER ONE example 2


Example 2:
find the area of celcius
celcius = (5/9) * ( fahrenheit-32)

Algorithm

1.get the fahrenheit of celcius
2.calculate celcius equal to 5 devide by multiply by fahrenheit minus 32
3.display the area of celcius

Pseudocode:

1.read fahrenheit
2.set the celcius = (5/9) * ( fahrenheit - 32 )
3.print output
coret curhat karra mc'yudied at 2:32 AM 0 comments

CHAPTER ONE example 1


Example 1 :
Find the area of rectangle
Area = width * height

Algorithm

1.Get the width of rectangle
2.Get the height of rectangle
3.Calculate the area of rectangle with multiply width by height
4.Display the area of rectangle

Pseudocode

1.Read width
2.Read Height
3.Set the area = width * height
4.Print output

coret curhat karra mc'yudied at 2:25 AM 0 comments

CHAPTER ONE

ALGORITHM – Is sequences of instruction to solve a problem
PSEUDOCODE – Is the textual approach to illustrate an algorithm while flowchart is a graphical approach to illustrate an algorithm


coret curhat karra mc'yudied at 2:04 AM 0 comments
Newer Posts » Home
Subscribe to: Posts (Atom)

MusicPlaylist
Music Playlist at MixPod.com

Followers

counters counters
counters
 stalkers reading

chit chakkks

Blog Archive

  • ▼  2011 (16)
    • ►  February (9)
      • CHAPTER ONE
      • CHAPTER ONE example 1
      • CHAPTER ONE example 2
      • CHAPTER ONE example 3
      • CHAPTER TWO
      • CHAPTER TWO example 1
      • EXERCISE C1 & C2
      • CHAPTER THREE programming
      • CHAPTER THREE
    • ▼  March (7)
      • IF ELSE TO SWITCH CASE
      • LOOP AND WHILE
      • EXERCISE exam
      • EXERCISE 2
      • ASSIGNMENT 1
      • CORDING ASSIGNMENT 1
      • ASSIGNMENT 2

About Me

My photo
karra mc'yudied
stupid naive falling in love.. very sensitive n secretive.. love to be alone..
View my complete profile
Karra Mc'yudied II

Create your badge
Karra Mc'yudied

Create your badge

i heart u most

i heart u most
 
Copyright © FUNDAMENTAL OF PROGRAMMING. All rights reserved.
Blogger templates created by Templates Block
Wordpress theme by Uno Design Studio