Ravi Tutorials Provide Project Training

ObjectOrientedProgramming



//include headers; these are modules that include functions that you may use in your

 //program; we will almost always need to include the header that

// defines cin and cout; the header is called iostream.h

#include <iostream.h>


int main() {


//variable declaration

//read values input from user

//computation  and print output to user

return 0;

}


After you write a C++ program you compile it; that is, you run a program called compiler that checks whether the program follows the C++ syntax

–if it finds errors, it lists them

–If there are no errors, it translates the C++ program into a program in machine  language which you can execute
Notes: 


•what follows after // on the same line is considered comment

•

•indentation is for the convenience of the reader; compiler ignores all spaces and new line ; the delimiter for the compiler is the semicolon

•

•all statements ended by semicolon

•

•Lower vs. upper case matters!!

–Void is different than void

–Main is different that main

The infamous
Hello world program




When learning a new language, the first program people usually write is one that salutes the world :)
Here is the Hello world program in C++.
#include <iostream.h>
int main() {
cout << “Hello world!”;
return 0;
}
Variable declaration



type variable-name;
Meaning: variable <variable-name> will be a variable of type <type>
Where type can be:
–int //integer
–double //real number
–char //character
–
–
Example:
int a, b, c;
double x;
int sum;
char my-character;









•