460 likes | 480 Views
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
E N D
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
Simple Assignment Don’t forget the semicolon !! Syntax: variable = expression ; ITC2223 - Computer Programming 1
Assignment Statement There are 3 types of assignment: Simple Multiple Shorthand ITC2223 - Computer Programming 1
Assignment Statement There are 3 types of assignment: Simple Multiple Shorthand ITC2223 - Computer Programming 1
Assignment Statement There are 3 types of assignment: Simple Multiple Shorthand ITC2223 - Computer Programming 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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Assignment Statement There are 3 types of assignment: Simple Multiple Shorthand ITC2223 - Computer Programming 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
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
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
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
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
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
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
Assignment Statement There are 3 types of assignment: Simple Multiple Shorthand ITC2223 - Computer Programming 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