First tutorial
1 ) . C++ is a
high level programming language.
typically , the first programm
begginers write is a programme called "hello world " which simply
prints hello world to our computer screen.
Although it is very simple , it contains all the fundamental
components c++ pogramms have.
//my first program in c++
#include<iostream>
int main()
{
std::cout<<”hello
world”;
}
|
hello world!
|
We should be careful for these things
1. Every
statement ends with semicolon ( ; )
2. We can also
write the code without writing preprocessor directories i.e. (#include<iostream>)
3. We can also
write only (cout<<”hello world”;) instead of std::cout <<”hello
world”; but we have to write this line
first
[ using
namespace std ;]
We have to write this statement
before (int main)
4. We also
write comments by using “ */,*/” these symbols
Variables and types
In previous code we saw that we wrote a program “hello world
“ and simply execute it as a output.
But what the use fullness of this operation however
programming is not limited only to printing simply text on the screen we write
programs that perform useful tasks that really saves our work , we needs to
introduce the concept of variables .
Take
a look
a = 5;
b = 6;
a= a+1;
result = a-b;
|
This is a very simple example , since we have only used two
small integer values , but consider that our computer can store millions of
numbers.
We can define a variable as a portion of memory to store a
value.
