Mari belajar asas c++
Page 1 of 1
Mari belajar asas c++
#include<iostream.h>
void main()
{
int a;
cout<<â€Sila Masukkan Satu Nombor:â€;
cin>>a;
cout<<â€Nombor yang dimasukkan ialah:â€<<a;
cout<<endl;
}
#include<iostream.h> // preprocessor
void main() // main function
{ // starting function body
char name[10];
const int Year=2009; // define variable
int YearBorn,Age;
cout<<"This program is use to calculate your age"<<endl; // show output to user "This program is use to calculate your age"
cout<<"and determine whether you are qualify to vote"<<endl; // show output to user "and determine whether you are qualify to vote"
cout<<endl<<"Please key-in your name : "; // endl is use to show output in new line
// show output to user "Please key-in your name"
cin.getline(name,20); // data will key in to variable name and cannot over than 20 letters
cout<<endl<<"YearBorn : "; // show output to user "YearBorn"
cin>>YearBorn; // data will key in to variable YearBorn
cin.get(); // cin.get is use for variable interger and to recall back data
Age=Year-YearBorn; // calculate age
cout<<endl<<"Hello, "<<name<<endl<<"You are "<<Age<<" years old."<<endl; // show output to user "Hello" and recall data from variable name and in new line show output "You are" and recall data from variable age and show output " years old."
if(Age>21) // selection structure where's age must over than 21
cout<<"You are qualify to vote!"<<endl; // show output to user "You are qualify to vote!"
else // selection structure else if user under 21
cout<<"Sorry, You are not qualify to vote!"<<endl; // show output to user "Sorry, You are not qualify to vote!"
cout<<"Thank you for using this program!"; // show output to user "Thanks you for using the program!"
} // ending function body
void main()
{
int a;
cout<<â€Sila Masukkan Satu Nombor:â€;
cin>>a;
cout<<â€Nombor yang dimasukkan ialah:â€<<a;
cout<<endl;
}
#include<iostream.h> // preprocessor
void main() // main function
{ // starting function body
char name[10];
const int Year=2009; // define variable
int YearBorn,Age;
cout<<"This program is use to calculate your age"<<endl; // show output to user "This program is use to calculate your age"
cout<<"and determine whether you are qualify to vote"<<endl; // show output to user "and determine whether you are qualify to vote"
cout<<endl<<"Please key-in your name : "; // endl is use to show output in new line
// show output to user "Please key-in your name"
cin.getline(name,20); // data will key in to variable name and cannot over than 20 letters
cout<<endl<<"YearBorn : "; // show output to user "YearBorn"
cin>>YearBorn; // data will key in to variable YearBorn
cin.get(); // cin.get is use for variable interger and to recall back data
Age=Year-YearBorn; // calculate age
cout<<endl<<"Hello, "<<name<<endl<<"You are "<<Age<<" years old."<<endl; // show output to user "Hello" and recall data from variable name and in new line show output "You are" and recall data from variable age and show output " years old."
if(Age>21) // selection structure where's age must over than 21
cout<<"You are qualify to vote!"<<endl; // show output to user "You are qualify to vote!"
else // selection structure else if user under 21
cout<<"Sorry, You are not qualify to vote!"<<endl; // show output to user "Sorry, You are not qualify to vote!"
cout<<"Thank you for using this program!"; // show output to user "Thanks you for using the program!"
} // ending function body
ni ade Video ZTutorial Sekali
http://rapidshare.com/files/149040960/1 ... oWorld.rar
http://rapidshare.com/files/149042003/2 ... iables.rar
http://rapidshare.com/files/149043935/3 ... tement.rar
http://rapidshare.com/files/149043550/4 ... _gates.rar
http://rapidshare.com/files/149044174/5 ... rLoops.rar
http://rapidshare.com/files/149044992/6 ... hmetic.rar
http://rapidshare.com/files/149045152/7 ... _Codes.rar
http://rapidshare.com/files/149046324/8_Cpp_Arrays.rar
http://rapidshare.com/files/149046405/9_switch.rar
http://rapidshare.com/files/149047075/10_goto.rar
http://rapidshare.com/files/149047605/11_2d_Arrays.rar
http://rapidshare.com/files/149048005/1 ... _procs.rar
http://rapidshare.com/files/149048220/13_procs.rar
http://rapidshare.com/files/149048206/1 ... _procs.rar
http://rapidshare.com/files/149048407/15_const.rar
http://rapidshare.com/files/149048969/1 ... arrays.rar
Pasword:tbdteam
http://210.48.146.76/~ahaqnet/70_C__.rar
http://rapidshare.com/files/149042003/2 ... iables.rar
http://rapidshare.com/files/149043935/3 ... tement.rar
http://rapidshare.com/files/149043550/4 ... _gates.rar
http://rapidshare.com/files/149044174/5 ... rLoops.rar
http://rapidshare.com/files/149044992/6 ... hmetic.rar
http://rapidshare.com/files/149045152/7 ... _Codes.rar
http://rapidshare.com/files/149046324/8_Cpp_Arrays.rar
http://rapidshare.com/files/149046405/9_switch.rar
http://rapidshare.com/files/149047075/10_goto.rar
http://rapidshare.com/files/149047605/11_2d_Arrays.rar
http://rapidshare.com/files/149048005/1 ... _procs.rar
http://rapidshare.com/files/149048220/13_procs.rar
http://rapidshare.com/files/149048206/1 ... _procs.rar
http://rapidshare.com/files/149048407/15_const.rar
http://rapidshare.com/files/149048969/1 ... arrays.rar
Pasword:tbdteam
http://210.48.146.76/~ahaqnet/70_C__.rar
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|