
STEP2

STEP3

STEP4

STEP 5

STEP 6

STEP7

STEP8
CLICK RUNQUESTION 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:"<


1. Go to my Computer at desktop.
2. Go to Local Disc C.
3. Click at TC's file show.
4. Click at BIN.
5. Click at TC's application.
6. Click NEW.
7. Type data ( quesion given before ).
8. After done insert data, click COMPILE.
10. Click RUN .
11. After all process insert data, compile, run done..users may insert any data (eg: number as picture show).
Int | Integer | |
Float | Float | Decimal |
Double | Double | Decimal |
Char | Character | a-z /A-Z |
String | String | Sentences |
Const | Constant | Tak berubah |