Tuesday, February 22, 2011

Weekly Reflection 2 : Chapter 2 : C++ Basics

C++ Language

consists of 2 basic elements :
  • semantics : a vocabulary of commands that humans can understand and that can be converted into machine language.
  • syntax : a language structure (or grammar) that allows humans to combine these C++ commands into a program that actually does something.
C++ Program

- is a text file containing a sequence of C++ commands put together according to the laws of C++ grammar.

__________ . CPP

# include <iostream.h>  = header
- - - - - - - - - - - - - - - - - - - - - - - - (start)
main (  ) = start
{ // open curly braket
                                        = body
} // close curly braket
- - - - - - - - - - - - - - - - - - - - - - - -(end)

In body

1. Variable
      to declare variable
      data_type  variable _name

Data_type
int          :  integar = real 0-9 only
float       :  float    = decimal
double   :  double = decimal
const      : constant = formula akan jd statik
char       : character = one alphabet only a-z
string     : string = one/more word

2. Input
cout<<"please enter your radius";
cin>>radius;

3. Output
cout<<"area = " << area ;

example :





No comments:

Post a Comment