1 / 46

Simple Assignment

Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _. Buying price: 10.00 Discount rate: _. Simple Assignment. Buying price: 10.00 _. Buying price: 10.00 Discount rate: 0.25 _. Buying price: 10.00 Discount rate: 0.25

Download Presentation

Simple Assignment

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  2. Simple Assignment Don’t forget the semicolon !! Syntax: variable = expression ; ITC2223 - Computer Programming 1

  3. Assignment Statement There are 3 types of assignment: Simple Multiple Shorthand ITC2223 - Computer Programming 1

  4. Assignment Statement There are 3 types of assignment: Simple Multiple Shorthand ITC2223 - Computer Programming 1

  5. Assignment Statement There are 3 types of assignment: Simple Multiple Shorthand ITC2223 - Computer Programming 1

  6. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  7. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  8. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  9. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  10. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  11. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  12. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  13. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  14. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  15. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  16. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  17. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  18. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  19. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  20. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  21. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  22. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  23. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  24. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  25. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  26. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  27. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  28. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  29. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  30. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  31. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  32. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  33. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  34. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  35. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  36. Assignment Statement There are 3 types of assignment: Simple Multiple Shorthand ITC2223 - Computer Programming 1

  37. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  38. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  39. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  40. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  41. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  42. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  43. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

  44. Assignment Statement There are 3 types of assignment: Simple Multiple Shorthand ITC2223 - Computer Programming 1

  45. Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 The total price is RM7.50 _ Buying price: 10.00 Discount rate: _ Simple Assignment Buying price: 10.00 _ Buying price: 10.00 Discount rate: 0.25 _ Buying price: 10.00 Discount rate: 0.25 For buying price RM10.00 and discount rate 0.25 _ Buying price: _ price 10.00 ?? ?? discount 0.25 total ?? • Example: • #include <iostream.h> • void main( ) { • float price, discount, total; • cout<<“Buying price :”; • cin>>price; • cout<<“\nDiscount rate :”; • cin>>discount; • total = price – (price * discount); • cout<<“\nFor buying price RM “<< price << • “ and discount rate “ << discount << endl; • cout<<“The total price is RM%.2f\n”; • } 7.50 ITC2223 - Computer Programming 1

More Related