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
Newer Posts » « Older 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)
    • ▼  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