STEP2
STEP3
STEP4
STEP 5
STEP 6
STEP7
STEP8CLICK RUN
QUESTION 1:
a) intializing variable pi with the value 3.14
ans: float pi = 3.14
b) Declare a variable named parameter with double data type
ans: Double perimeter;
c) Give instruction that allowed user to input data
ans: cout<< "enter your data";
cin>> data;
d) Input number of computer using variable
ans:cout<<"enter number";
cin>>number;
QUESTION 2:
Change the if....else statement below to switch....case statement
#include
main ()
{
int selection,quantity;
float price;
cout<<"1.pen = Rm0.50";
cout<<"2.pencil = Rm0.30";
cout<<"3.ruler = Rm0.20";
cout<<"4.eraser = Rm0.10";
cin>>selection;
cin>>quantity;
if (selection = =1)
{ price = quantity * 0.50;}
else if (selection = =2)
{ price = quantity * 0.30;}
else if (selection = =3)
{ price = quantity * 0.20;}
else if (selection = = 4)
{ price = quantity * 0.10;}
else
{ cout <<"invalid selection";}
cout<<"the price is : "<
QUESTION 1
change the if....else statements below to switch.....case statements:
#include
main()
{
int nom A,nom B,Selection,Value;
cout<<"enter 2 numbers:";
cin>>nomA >>nomB;
cout<<"1.addition";
cout<"2.subtraction";
cout<<"3.multiply";
cout<<"4.division";
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";}
<<"the value is:"<