#include <iostream.h>
main ()
{
int a,b;
for (a=1;a<=12;a++)
{
cout<<"\n";
for (b=1;b<=12;b++)
{cout<<" "<<a*b;}
}
return 0;
}
Followers
Saturday, March 26, 2011
Sunday, March 20, 2011
TIN MINUMAN
#include <iostream.h>
main()
{
//declare
int selection;
float money,balance,price,addmmoney,add;
//out
cout<<"\n******************";
cout<<"\nMesin Tin Minuman";
cout<<"\n------------------";
cout<<"\n1.PEPSI";
cout<<"\n2.COCA COLA";
cout<<"\n3.F&N MIRINDA";
cout<<"\n4.F&N ORANGE";
cout<<"\n5.100 PLUS";
cout<<"\n******************";
//input
cout<<"\nPlease Choose Your Drink=";
cin>>selection;
cout<<"\nPlease Enter MONEY: ";
cin>>money;
switch (selection)
{
case 1: cout<<" Your drink is Pepsi";
price = 2.00;
break;
case 2: cout<<" Your drink is Coca Cola";
price = 2.00;
break;
case 3: cout<<" Your drink is F&N Mirinda";
price = 1.80;
break;
case 4: cout<<" Your drink is F&N Orange";
price = 1.80;
break;
case 5: cout<<" Your drink is 100 Plus";
price = 2.50;
break;
default: cout<<"invalid selection";
}
if (money>price)
{
balance = money - price;
}else if (money<price)
{
add = price - money;
cout<<"Please add (RM" <<add<< ")= ";
cin>>addmoney;
balance = money + addmoney;
}
cout<<"Your balance is ";
return 0;
}
main()
{
//declare
int selection;
float money,balance,price,addmmoney,add;
//out
cout<<"\n******************";
cout<<"\nMesin Tin Minuman";
cout<<"\n------------------";
cout<<"\n1.PEPSI";
cout<<"\n2.COCA COLA";
cout<<"\n3.F&N MIRINDA";
cout<<"\n4.F&N ORANGE";
cout<<"\n5.100 PLUS";
cout<<"\n******************";
//input
cout<<"\nPlease Choose Your Drink=";
cin>>selection;
cout<<"\nPlease Enter MONEY: ";
cin>>money;
switch (selection)
{
case 1: cout<<" Your drink is Pepsi";
price = 2.00;
break;
case 2: cout<<" Your drink is Coca Cola";
price = 2.00;
break;
case 3: cout<<" Your drink is F&N Mirinda";
price = 1.80;
break;
case 4: cout<<" Your drink is F&N Orange";
price = 1.80;
break;
case 5: cout<<" Your drink is 100 Plus";
price = 2.50;
break;
default: cout<<"invalid selection";
}
if (money>price)
{
balance = money - price;
}else if (money<price)
{
add = price - money;
cout<<"Please add (RM" <<add<< ")= ";
cin>>addmoney;
balance = money + addmoney;
}
cout<<"Your balance is ";
return 0;
}
Sunday, March 6, 2011
HOMEWORK 2
#include<iostream.h>
main()
{
//variable
float subject1,subject2,subject3,subject4,subject5,cgpa;
//input 1
cout<<"subject1 pointer=";
cin>>subject1;
//input 2
cout<<"subject2 pointer=";
cin>>subject2;
//input 3
cout<<"subject3 pointer=";
cin>>subject3;
//input 4
cout<<"subject4 pointer=";
cin>>subject4;
//input 5
cout<<"subject5 pointer=";
cin>>subject5;
//formula
cgpa=((sub1*3)+(sub2*3)+(sub3*2)+(sub4*2)+(sub5*4))/5;
//output
cout<<"subject1 is="<<sub1;
cout<<"subject2 is="<<sub2;
cout<<"subject3 is="<<sub3;
cout<<"subject4 is="<<sub4;
cout<<"subject5 is="<<sub5;
cout<<"The cgpa is="<<cgpa;
return 0;
}
main()
{
//variable
float subject1,subject2,subject3,subject4,subject5,cgpa;
//input 1
cout<<"subject1 pointer=";
cin>>subject1;
//input 2
cout<<"subject2 pointer=";
cin>>subject2;
//input 3
cout<<"subject3 pointer=";
cin>>subject3;
//input 4
cout<<"subject4 pointer=";
cin>>subject4;
//input 5
cout<<"subject5 pointer=";
cin>>subject5;
//formula
cgpa=((sub1*3)+(sub2*3)+(sub3*2)+(sub4*2)+(sub5*4))/5;
//output
cout<<"subject1 is="<<sub1;
cout<<"subject2 is="<<sub2;
cout<<"subject3 is="<<sub3;
cout<<"subject4 is="<<sub4;
cout<<"subject5 is="<<sub5;
cout<<"The cgpa is="<<cgpa;
return 0;
}
HOMEWORK 1
#include<iostream.h>
main ()
{
//variable
float Asmnt1,Asgm2,Asmnt3,Asmnt4,Asmnt5,midterm,final,total;
//input 1
cout<<"Assignment1 score=";
cin>>Asmnt1;
//input 2
cout<<"Assignment2 score=";
cin>>Asmnt2;
//input 3
cout<<"Assignment3 score=";
cin>>Asmnt3;
//input 4
cout<<"Assignment4 score=";
cin>>Asmnt4;
//input 5
cout<<"Assignment5 score=";
cin>>Asmnt5;
//input 6
cout<<"Midterm score=";
cin>>midterm;
//input 7
cout<<"Final score=";
cin>>final;
//formula
total=Agntm1+Asmnt2+Asmnt3+Asmnt4+Asmnt5+midterm+final;
//output
cout<<"Assignment1 is="<<Asmnt1;
cout<<"Assignmnet2 is="<<Asmnt2;
cout<<"Assignment3 is="<<Asmnt3;
cout<<"Assignment4 is="<<Asmnt4;
cout<<"Assignment5 is="<<Asmnt5;
cout<<"Midterm is="<<midterm;
cout<<"Final is="<<final;
cout<<"Total is="<<total;
return 0;
}
main ()
{
//variable
float Asmnt1,Asgm2,Asmnt3,Asmnt4,Asmnt5,midterm,final,total;
//input 1
cout<<"Assignment1 score=";
cin>>Asmnt1;
//input 2
cout<<"Assignment2 score=";
cin>>Asmnt2;
//input 3
cout<<"Assignment3 score=";
cin>>Asmnt3;
//input 4
cout<<"Assignment4 score=";
cin>>Asmnt4;
//input 5
cout<<"Assignment5 score=";
cin>>Asmnt5;
//input 6
cout<<"Midterm score=";
cin>>midterm;
//input 7
cout<<"Final score=";
cin>>final;
//formula
total=Agntm1+Asmnt2+Asmnt3+Asmnt4+Asmnt5+midterm+final;
//output
cout<<"Assignment1 is="<<Asmnt1;
cout<<"Assignmnet2 is="<<Asmnt2;
cout<<"Assignment3 is="<<Asmnt3;
cout<<"Assignment4 is="<<Asmnt4;
cout<<"Assignment5 is="<<Asmnt5;
cout<<"Midterm is="<<midterm;
cout<<"Final is="<<final;
cout<<"Total is="<<total;
return 0;
}
Saturday, March 5, 2011
PROGRAMMING EXERCISE 2
#include<iostream.h>
main()
{
int number1,number2,number3;
float calculate;
cout<<"enter num1=";
cin>>number1;
cout<<"enter num2=";
cin>>number2;
cout<<"enter num3=";
cin>>number3;
calculate=(number1*number2)-number3+(number2/number1);
cout<<"num1="<<number1;
cout<<"num2="<<number2;
cout<<"num3="<<number3;
cout<<"calculate="<<calculate;
return 0;
}
PROGRAMMING EXERCISE 1
#include<iostream.h>
main()
{
float celcius,farenheit;
cout<<"enter celcius=";
cin>>celcius;
farenheit=9/5*(celcius+32);
cout<<"celcius="<<celcius;
cout<<"farenheit="<<farenheit;
return 0;
}
Tuesday, March 1, 2011
ANSWER EXERCISE (IF ELSE & SWITCH CASE)
2. CALCULATE (IF...ELSE)
CALCULATE:
a) RECTANGULAR
b) TRIANGLE
c) CIRCLE
d) FAHRENHEIT
e) CELCIUS
Your Selection:
Your Selection is _________ and you are calculate _________. The answer is _____________
ANSWER.
2)#include<iostream.h>
main()
{
char a,b,c,d,e,selection;
float rectangle,triangle,circle,fahrenheit,celcius,h1,h2,w1,b1,f1,r1,c1;
cout<<"\ncalculate:-";
cout<<"\na)rectangular";
cout<<"\nb)triangle";
cout<<"\nc)circle";
cout<<"\nd)fahrenheit";
cout<<"\ne)celcius";
cout<<"\n\n Enter your selection=";
cin >>selection;
if (selection=='a' || selection=='A')
{
cout<<"Enter your height=";
cin>>h1;
cout<<"Enter your width=";
cin>>w1;
rectangle=h1*w1;
cout<<"Your selection is a and you are calculate rectangular.the answer is="<< rectangle;
}
else if(selection=='b'|| selection=='B')
{
cout<<"Enter your base=";
cin>>b1;
cout<<"Enter your height=";
cin>>h2;
triangle=0.5*b1*h2;
cout<<"Your selection is b and you are calculate triangle.the answer is="<< triangle;
}
else if(selection=='c' || selection=='C')
{
cout<<"Enter your radius=";
cin>>r1;
circle=3.1452*r1*r1;
cout<<"Your selection is c and you are calculate circle.the answer is="<< circle;
}
else if(selection=='d' || selection=='D')
{
cout<<"Enter your celcius=";
cin>>c1;
fahrenheit=1.8*(c1+32);
cout<<"Your selection is d and you are calculate fahrenheit.the answer is="<< fahrenheit;
}
else if(selection=='e' || selection=='E')
{
cout<<"Enter your fahrenheit=";
cin>>f1;
celcius=0.56*(f1-32);
cout<<"Your selection is e and you are calculate celcius.the answer is="<< celcius;
}
else
{ cout<<"Invalid selection";}
return 0;
}
CALCULATE:
a) RECTANGULAR
b) TRIANGLE
c) CIRCLE
d) FAHRENHEIT
e) CELCIUS
Your Selection:
Your Selection is _________ and you are calculate _________. The answer is _____________
ANSWER.
2)#include<iostream.h>
main()
{
char a,b,c,d,e,selection;
float rectangle,triangle,circle,fahrenheit,celcius,h1,h2,w1,b1,f1,r1,c1;
cout<<"\ncalculate:-";
cout<<"\na)rectangular";
cout<<"\nb)triangle";
cout<<"\nc)circle";
cout<<"\nd)fahrenheit";
cout<<"\ne)celcius";
cout<<"\n\n Enter your selection=";
cin >>selection;
if (selection=='a' || selection=='A')
{
cout<<"Enter your height=";
cin>>h1;
cout<<"Enter your width=";
cin>>w1;
rectangle=h1*w1;
cout<<"Your selection is a and you are calculate rectangular.the answer is="<< rectangle;
}
else if(selection=='b'|| selection=='B')
{
cout<<"Enter your base=";
cin>>b1;
cout<<"Enter your height=";
cin>>h2;
triangle=0.5*b1*h2;
cout<<"Your selection is b and you are calculate triangle.the answer is="<< triangle;
}
else if(selection=='c' || selection=='C')
{
cout<<"Enter your radius=";
cin>>r1;
circle=3.1452*r1*r1;
cout<<"Your selection is c and you are calculate circle.the answer is="<< circle;
}
else if(selection=='d' || selection=='D')
{
cout<<"Enter your celcius=";
cin>>c1;
fahrenheit=1.8*(c1+32);
cout<<"Your selection is d and you are calculate fahrenheit.the answer is="<< fahrenheit;
}
else if(selection=='e' || selection=='E')
{
cout<<"Enter your fahrenheit=";
cin>>f1;
celcius=0.56*(f1-32);
cout<<"Your selection is e and you are calculate celcius.the answer is="<< celcius;
}
else
{ cout<<"Invalid selection";}
return 0;
}
EXERCISES IF...ELSE & SWITCH....CASE
1. MESIN TIN MINUMAN (SWITCH...CASE & IF...ELSE)
*************************
MESIN TIN MINUMAN
--------------------
1- PEPSI
2- COCA COLA
3- F&N MIRINDA
4- F&N ORANGE
5- 100 PLUS
*************************
Enter your drink:
Enter your money (RM):
Your drink is __________ and your balance are __________
*If the customer does not enter enough money, asked the customer to insert the money. (if...else)
2. CALCULATE (IF...ELSE)
CALCULATE:
a) RECTANGULAR
b) TRIANGLE
c) CIRCLE
d) FAHRENHEIT
e) CELCIUS
Your Selection:
Your Selection is _________ and you are calculate _________. The answer is _____________
*************************
MESIN TIN MINUMAN
--------------------
1- PEPSI
2- COCA COLA
3- F&N MIRINDA
4- F&N ORANGE
5- 100 PLUS
*************************
Enter your drink:
Enter your money (RM):
Your drink is __________ and your balance are __________
*If the customer does not enter enough money, asked the customer to insert the money. (if...else)
2. CALCULATE (IF...ELSE)
CALCULATE:
a) RECTANGULAR
b) TRIANGLE
c) CIRCLE
d) FAHRENHEIT
e) CELCIUS
Your Selection:
Your Selection is _________ and you are calculate _________. The answer is _____________
weekly reflection 5 pulak ye..
1)ari ni aku dtg lmbt,..sbb bgn lmbt..tp aku ttp g kelas....sbb kelas Fop ni penting..dah ar susah...
2)kol 10 baru aku masok kelas..
3)masok kelas je..miss suruh buat exercises programing...
-buat exercises if else & switch case.
-ade dua jenis soalan..1 mesti kene buat ari ni..,.klu x miss x bg balik...kene lah jugak buat walaupon susah...
1. MESIN TIN MINUMAN (SWITCH...CASE & IF...ELSE)
*************************
MESIN TIN MINUMAN
--------------------
1- PEPSI
2- COCA COLA
3- F&N MIRINDA
4- F&N ORANGE
5- 100 PLUS
*************************
Enter your drink:
Enter your money (RM):
Your drink is __________ and your balance are __________
*If the customer does not enter enough money, asked the customer to insert the money. (if...else)
2. CALCULATE (IF...ELSE)
CALCULATE:
a) RECTANGULAR
b) TRIANGLE
c) CIRCLE
d) FAHRENHEIT
e) CELCIUS
Your Selection:
Your Selection is _________ and you are calculate _________. The answer is _____________
4)kumpulan kami dpt buat soalan no 2 je..no 1 x dapat disiap kan...
5)miss suruh masok kan weekly reflection kat dlm blog masing,...
6)lepas tu miss bg balik...hureyyyyyyyyyyyyyy!!
2)kol 10 baru aku masok kelas..
3)masok kelas je..miss suruh buat exercises programing...
-buat exercises if else & switch case.
-ade dua jenis soalan..1 mesti kene buat ari ni..,.klu x miss x bg balik...kene lah jugak buat walaupon susah...
1. MESIN TIN MINUMAN (SWITCH...CASE & IF...ELSE)
*************************
MESIN TIN MINUMAN
--------------------
1- PEPSI
2- COCA COLA
3- F&N MIRINDA
4- F&N ORANGE
5- 100 PLUS
*************************
Enter your drink:
Enter your money (RM):
Your drink is __________ and your balance are __________
*If the customer does not enter enough money, asked the customer to insert the money. (if...else)
2. CALCULATE (IF...ELSE)
CALCULATE:
a) RECTANGULAR
b) TRIANGLE
c) CIRCLE
d) FAHRENHEIT
e) CELCIUS
Your Selection:
Your Selection is _________ and you are calculate _________. The answer is _____________
4)kumpulan kami dpt buat soalan no 2 je..no 1 x dapat disiap kan...
5)miss suruh masok kan weekly reflection kat dlm blog masing,...
6)lepas tu miss bg balik...hureyyyyyyyyyyyyyy!!
jawapan exercises 1 tu..
1. Write correct C++ syntax & for each statement below:
a) Initializing variable Pi with the value 3.14 (constant)
const double Pi = 3.14;
b) Declare a variable named Parameter with double data type (declare variable)
double Parameter;
c) Give instruction that allowed user to input data (input)
cout<<"input data";
cin>>data;
cin>>num_compt;
4. Write a program that will calculate the monthly salary for an employee that where Saturday and Sunday are considered as non-working days.
answer
#include<iostream.h>
main()
{
float salaryperhour,monthlysalary;
cout<<"enter salaryperhour=";
cin>>salaryperhour;
monthlysalary*salaryperhour;
cout<<"monthlysalary"<<salaryperhour;
return 0;
}
a) Initializing variable Pi with the value 3.14 (constant)
const double Pi = 3.14;
b) Declare a variable named Parameter with double data type (declare variable)
double Parameter;
c) Give instruction that allowed user to input data (input)
cout<<"input data";
cin>>data;
d) Input number of computer using variable (input assign to variable value
int num_compt;
cout<<"input number of computer";cin>>num_compt;
2. Solve the question below. Show the working.
a) 5 * 2 % 3 + 25 / 5
=10%3+25/5
= 1+5
= 6
=10%3+25/5
= 1+5
= 6
b) a = 5, b = 6 !((a < a ="="> 9))
!((5 < 5 ="="> 9))
!(1 && 0 0 )
!(00)
!(0)
1
!((5 < 5 ="="> 9))
!(1 && 0 0 )
!(00)
!(0)
1
3) Identify syntax errors in the following program.
include<iostream.h>
main()
{
float allowance = 300.00, salary;
cout<<"Input Salary = ";
cin>>salary;
TSalary = salary + Allowance;
cout<<"Salary is= "<< salary;
}
include<iostream.h>
main()
{
float allowance = 300.00, salary;
cout<<"Input Salary = ";
cin>>salary;
TSalary = salary + Allowance;
cout<<"Salary is= "<< salary;
}
4. Write a program that will calculate the monthly salary for an employee that where Saturday and Sunday are considered as non-working days.
answer
#include<iostream.h>
main()
{
float salaryperhour,monthlysalary;
cout<<"enter salaryperhour=";
cin>>salaryperhour;
monthlysalary*salaryperhour;
cout<<"monthlysalary"<<salaryperhour;
return 0;
}
5. Write a program that calculates the average of 5 numbers that can be input by user.
answer
#include<iostream.h>
main()
{
int number1, number2, number3, number4, number5, average;
cout<<"enter 5 numbers";
cin>>number1;
cin>>number2;
cin>>number3;
cin>>number4;
cin>>number5;
average= (number1+number2+number3+number4+number5)/5
cout<<"total average="<<average;
return 0;
}
#include<iostream.h>
main()
{
int number1, number2, number3, number4, number5, average;
cout<<"enter 5 numbers";
cin>>number1;
cin>>number2;
cin>>number3;
cin>>number4;
cin>>number5;
average= (number1+number2+number3+number4+number5)/5
cout<<"total average="<<average;
return 0;
}
6. Write a program that will calculate the area of rectangular, triangle and circle.
answer
finishhhh!!!!
Subscribe to:
Posts (Atom)