Question 1
a)Float Pi=”3.14”;
b)double perimeter;
c) int data;
cout<<”Enter your data “;
cin>>data;
d) int num;
cout<<”Enter your num “;
cin>>num;
Question 2
#include <iostream.h>
main()
{
Int selection,quantity;
float price;
cout << “1 Pen = RM0.50”;
cout << “2 Pensil = RM0.30”;
cout << “3 Rules = RM0.20”;
cout << “4 Erasers = 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: "<<price;
return 0;
}
No comments:
Post a Comment