C++ BASICS
DATE : 2 FEB 2011 (WED)
DATE : 2 FEB 2011 (WED)
C++ language consists of two basic elements :-
1. Semantics
2. Syntax
How to create the programming ?
compulsory symbol before starting to create the programming
#include <IDStream.h> //header
Main ( ) // start body
{ // Open curly braket
} // close curly braket
// comment hidden
/ * , * /
Declare variable
Main ( ) // start body
{ // Open curly braket
} // close curly braket
// comment hidden
/ * , * /
Declare variable
Data_type and variable_name
int = integer 0-9
float = float (decimal)
double = double (decimal)
char = character (a-z / A-Z)
string = string (sentences)
const = constant ( tidak berubah )
Rules:
---->Tengok formula
---->Cari ade bape variable name
---->Declare variable
Input:
Cout <<“----------------------” ;
Cin >>variable_name_that_had_declared;
int = integer 0-9
float = float (decimal)
double = double (decimal)
char = character (a-z / A-Z)
string = string (sentences)
const = constant ( tidak berubah )
Rules:
---->Tengok formula
---->Cari ade bape variable name
---->Declare variable
Input:
Cout <<“----------------------” ;
Cin >>variable_name_that_had_declared;
WARNING : BE CAREFULL HURUF KECIL DAN BESAR
Output:
Cout <<“----------------------”<<
variable_name_that_had_declared;
EXAMPLE OF PROGRAMMING
Flow chart
start > read radius > area = 3.142 * radius * radius > print output
#include <iDStream.h>//header
Main( ) //start body
{ // Open curly braket
//declare variable
Float area;
Float radius;
// input 1
Cout <<“enter radius”;
Cin>> radius;
//formula
area = 3.142 *radius*radius
//output
Cout <<“answer”<<area ;
Return 0 ;
} // close curly bracket
//end bracket
Output:
Cout <<“----------------------”<<
variable_name_that_had_declared;
EXAMPLE OF PROGRAMMING
Flow chart
start > read radius > area = 3.142 * radius * radius > print output
#include <iDStream.h>//header
Main( ) //start body
{ // Open curly braket
//declare variable
Float area;
Float radius;
// input 1
Cout <<“enter radius”;
Cin>> radius;
//formula
area = 3.142 *radius*radius
//output
Cout <<“answer”<<area ;
Return 0 ;
} // close curly bracket
//end bracket
0 comments:
Post a Comment