haa akhir nyeeer . ciap gak due due ass yg mis suh wt niy . aq ta la hebat mane bole wt bnde niy sume sndry . tp aq discuss n tgok cntoh dpd blog ita . tnx ita ! (: even da lmbat, tp atleast aq da wat . hmm sorry mis . sy lmbat buat, n pasal mid term tuhhhhh ): sorryyyy jugaak . hehe :D:D
3/27/2011
ASSIGNMENT 2 !! :D
1) Write your program
2) Click save by enter your own file's name
3) Go to compile menu
4) Press any key for compiling the program
5) Go to run menu
6) Go to Window and click Output
7) Get the final output
ASSIGNMENT 1 !! :D
QUESTION :
Write a program :
* * * * * * * * * * * * * * * * *
M E S I N T I N M I N U M A N
- - - - - - - - - - - - - - - - -
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
ANSWER :
Step 1 :
Step 6 :
Write a program :
* * * * * * * * * * * * * * * * *
M E S I N T I N M I N U M A N
- - - - - - - - - - - - - - - - -
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
ANSWER :
Step 1 :
Step 2 :
Step 3 :
Step 4 :
Steap 5 :
Step 7 :
Step 8 : ( bile masukkan duit lebih dpd harga asal )
Step 9 :
Step 10 :
Step 11 :
Step 12 :
Step 13 :
Step 14 : ( bile masukkan duit kurang dpd harga asal )
Step 15 :
Step 16 :
Step 17 :
Step 18 :
Step 19 :
3/26/2011
homework again ! :D
1) Complete the code that can calculate total marks for 3 students
for(int stud=1;____(a)____;stud++)
{
cout<<"Enter Student name:";
____(b)____name;
for(int mark=1;mark<=3;____(c)____)
{
cout<<"Enter assigment marks:";
cin>>marks;
total=____(d)____+marks;
}
}
cout<<"Total marks are"<<____(e)____;
(a) stud<=3
(b) cin>>
(c) mark++
(d) total
(e) total
2) Based on the short code below :
Change for loop statement below to while loop
for(x=1;x<=5;x++)
cout<<x<<"\t"<<x*2<<"In";
x=1;
while(x<=5)
cout<<x<<"\t"<<x*2<<"In";
x++
3) Write the code using while loop to get the output as below !
20
15
10
5
x=20
while(x<=5)
cout<<" "<<x;
x--;
yg niy aq tataw betol ke tak . sbb nyeer mis blom check . so klu aq ade sala, tlg sesaper tego aq k ? tnx :))
for(int stud=1;____(a)____;stud++)
{
cout<<"Enter Student name:";
____(b)____name;
for(int mark=1;mark<=3;____(c)____)
{
cout<<"Enter assigment marks:";
cin>>marks;
total=____(d)____+marks;
}
}
cout<<"Total marks are"<<____(e)____;
(a) stud<=3
(b) cin>>
(c) mark++
(d) total
(e) total
2) Based on the short code below :
Change for loop statement below to while loop
for(x=1;x<=5;x++)
cout<<x<<"\t"<<x*2<<"In";
x=1;
while(x<=5)
cout<<x<<"\t"<<x*2<<"In";
x++
3) Write the code using while loop to get the output as below !
20
15
10
5
x=20
while(x<=5)
cout<<" "<<x;
x--;
yg niy aq tataw betol ke tak . sbb nyeer mis blom check . so klu aq ade sala, tlg sesaper tego aq k ? tnx :))
last exercise b4 our examination
1) Change the if...else statement below to switch...case statement
#include<iostream.h>
main()
{
int nomA,nomB,selection,value;
cout<<"Enter 2 number:";
cin>>nomA>>nomB;
cout<<"1.Addition";
cout<<"2.Substraction";
cout<<"3.Multiply";
cout<<"4.Division";
cout<<"Enter selection=";
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";}
cout<<"The value is:"<<value;
return 0;
}
#include<iostream.h>
main()
{
int nomA,nomB,selection,value;
cout<<"Enter 2 number:";
cin>>nomA>>nomB;
cout<<"1.Addition";
cout<<"2.Substraction";
cout<<"3.Multiply";
cout<<"4.Division";
cout<<"Enter selection=";
cin>>selection;
switch(selection)
{
case1:"value=nomA+nomB";break;
case2:"value=nomA-nomB";break;
case3:"value=nomA*nomB";break;
case4:"value=nomA/nomB";break;
default:cout<<"Invalid selection";
cout<<"The value is:"<<value;
}
return 0;
}
2) Change the for loop statement below to while loop
#include<iostream.h>
main()
{
int i,power2;
for(i=1;i<=9;i++)
{
power2=i*i;
cout<<" "<<i<<"power2"<<power2;
}
return 0;
}
#include<iostream.h>
main()
{
int i,power2;
//while
i=1;
while(i<=9)
{
power2=i*i;
cout<<" "<<i<<"power2"<<power2;
i++;
}
return 0;
}
3) Write a program that input 2 numbers. Compare the numbers & display only the biggest number. If the numbers are same, display the numbers are same.
#include<iostream.h>
main()
{
int nomA,nomB;
cout<<"Enter 2 numbers=";
cin>>nomA>>nomB;
if(nomA>nomB)
{cout<<"nom A is bigger than nom B";}
else if(nomA==nomB)
{cout<<"nom A is same as nom B";}
else
{cout<<"Invalid";}
return 0;
}
4) Write a program using for loop that receive prices of 3 products. Calculate the price that must be paid after 10% discount is given to every customer.
#include<iostream.h>
main()
{
int x,price,total,discount;
for(x=1;x<4;x++)
{
cout<<"price["<<x<<"]:";
cin>>price;
total=total+price;
}
cout<<"total="<<total;
discount=total*0.10;
cout<<"discount"<<discount;
return 0;
}
5) What is the output for the following program segmment
i) int x=20;
for(int i=5;i<=x;i++)
{
cout<<i;
i=i+4;
}
5
10
15
20
ii) int mul=1;
do
{
mul=mul*2;
cout<<"The mul is:"<<mul;
mul++;
}
while(mul<10)
1
3
7
#include<iostream.h>
main()
{
int nomA,nomB,selection,value;
cout<<"Enter 2 number:";
cin>>nomA>>nomB;
cout<<"1.Addition";
cout<<"2.Substraction";
cout<<"3.Multiply";
cout<<"4.Division";
cout<<"Enter selection=";
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";}
cout<<"The value is:"<<value;
return 0;
}
#include<iostream.h>
main()
{
int nomA,nomB,selection,value;
cout<<"Enter 2 number:";
cin>>nomA>>nomB;
cout<<"1.Addition";
cout<<"2.Substraction";
cout<<"3.Multiply";
cout<<"4.Division";
cout<<"Enter selection=";
cin>>selection;
switch(selection)
{
case1:"value=nomA+nomB";break;
case2:"value=nomA-nomB";break;
case3:"value=nomA*nomB";break;
case4:"value=nomA/nomB";break;
default:cout<<"Invalid selection";
cout<<"The value is:"<<value;
}
return 0;
}
2) Change the for loop statement below to while loop
#include<iostream.h>
main()
{
int i,power2;
for(i=1;i<=9;i++)
{
power2=i*i;
cout<<" "<<i<<"power2"<<power2;
}
return 0;
}
#include<iostream.h>
main()
{
int i,power2;
//while
i=1;
while(i<=9)
{
power2=i*i;
cout<<" "<<i<<"power2"<<power2;
i++;
}
return 0;
}
3) Write a program that input 2 numbers. Compare the numbers & display only the biggest number. If the numbers are same, display the numbers are same.
#include<iostream.h>
main()
{
int nomA,nomB;
cout<<"Enter 2 numbers=";
cin>>nomA>>nomB;
if(nomA>nomB)
{cout<<"nom A is bigger than nom B";}
else if(nomA==nomB)
{cout<<"nom A is same as nom B";}
else
{cout<<"Invalid";}
return 0;
}
4) Write a program using for loop that receive prices of 3 products. Calculate the price that must be paid after 10% discount is given to every customer.
#include<iostream.h>
main()
{
int x,price,total,discount;
for(x=1;x<4;x++)
{
cout<<"price["<<x<<"]:";
cin>>price;
total=total+price;
}
cout<<"total="<<total;
discount=total*0.10;
cout<<"discount"<<discount;
return 0;
}
5) What is the output for the following program segmment
i) int x=20;
for(int i=5;i<=x;i++)
{
cout<<i;
i=i+4;
}
5
10
15
20
ii) int mul=1;
do
{
mul=mul*2;
cout<<"The mul is:"<<mul;
mul++;
}
while(mul<10)
1
3
7
Exercise niy ktorang wt tyme mis wt extra class b4 exam . mis suh student wt kt white board . aq kne wt num 2 . pas uh aq sala sbb lupe na ltx semikolon . hmm cuai aq niy )= sume soalan niy mis da check n discuss nan ktorang . so jwpn dy insyallah betol (:
for loop & while loop pulaaak !
FOR LOOP
#include<iostream.h>
main()
{
//declare variable
int x,y;
cout<<"Enter an integer=";
cin>>x;
//loop for
for(y=1;y<x;y++)
{
cout<<" "<<x;
}
return 0;
}
WHILE LOOP
#include<iostream.h>
main()
{
//declare variable
int x,y;
cout<<"Enter an integer=";
cin>>x;
//while
y=x;
while(y<x)
{
cout<<" "<<x;
y++;
}
return 0;
}
#include<iostream.h>
main()
{
//declare variable
int x,y;
cout<<"Enter an integer=";
cin>>x;
//loop for
for(y=1;y<x;y++)
{
cout<<" "<<x;
}
return 0;
}
WHILE LOOP
#include<iostream.h>
main()
{
//declare variable
int x,y;
cout<<"Enter an integer=";
cin>>x;
//while
y=x;
while(y<x)
{
cout<<" "<<x;
y++;
}
return 0;
}
iklan jap ..
weyhhhh ! sedey gyleerr . aq tye kak syaza td, mcm ner xm . ok ke ko . then dy suh aq tgok fb kak lia . dy ckp mis ade komen kt wall kak lia about our xm tuhhh . aq check, aq bace dan aq kecewe )): hmm ciap sebut name aq lagi . adeeh miss kecewa mesty aq wt terok . hmm susa nye na score subject niy T T hmm lg satuu pasal ass yg mis bg uhhh . knp susa sgt haa ? mcm mne la aq na ciap kn . adeeh
Subscribe to:
Posts (Atom)

























