For this week ade jugak la faham sikit..itu pun di sebabkan rajin bertanya kepada yang expert....hehehe...
thanks to them kerana sudi memberi tunjuk ajar....
#include<iostream.h>//header
main()//start body
{//open curly bracket
}//close curly bracket
//end body
DECLARE VARIABLE
data type variable_ name
- int-integer
- float-float
- double-double
- char-character
- string-string
- const-constant
Question 1
Find the area of circle:
area=3.14* radius*radius
Answer
Start>>read radius>>area=3.14*radius*radius>>display output>>end
#include<iostream.h>//header
main()//start body
{//open curly bracket
//declare variable
float area;
float radius;
//input 1
cout<<"enter radius";
cin>>radius;
//formula
area=3.14*radius*radius
//output
cout<<"answer="<<area;
return 0;
}//close curly bracket
//end body
Question 2
Multiply and divide two FLOAT number, num 1 and num 2 with using the formula below:-
multiply=num 1*number 2
divide=num 2/num 1
Answer
Start>>read num 1,num 2>>multiply=num 1*num 2,divide=num 2/num 1>>display output>>end
#include<iostream.h>//header
main()start body
{//open curly bracket
//declare variable
float num 1;
float num 2
float multiply;
float divide;
//input 1
cout<<"num 1";
cin>>num 1;
//input 2
cout<<"num 2";
cin>>num 2;
//formula
multiply=num 1*num 2;
//output
cout<<"multiply="<<multiply;
//formula
divide=num 2/num 1;
//output
cout<<"divide="<<divide;
return 0;
}//close curly bracket
//end body
0 comments:
Post a Comment