Sunday 3 June 2018

Lesson 1-Starting with c++ - How to compile a c++ program? Coding overdose

Starting with c++ C++ is one of the most basic and most popular programming languages out there, The c++ has been used in making many computer software..you can have a look at various software that has c++ incorporated in its development.

top 10 applications written in c/ c++







(If you are using linux os, you don't need to download any compiler..)

1.Downloading c++ compiler (for Windows)

In order to compile a c++ program, you need to have a compiler..there are various c++ compilers out there.

.
code::blocks is one of those..

you can download that for free from following link.


Download code:block


after downloading code::blocks , install this program.


2.Making 1st c++ program- Hello world


now we are ready to see , how a c++ program is built and run.




  • open code::blocks 
  • go to file>new>empty file
  • type the following code in the compiler



#include <iostream>


using namespace std;


int main ()


{ cout<<"Hello World!";


return 0;


}







  • save the file by ctrl+s and name the file anything  you want but it should end in .cpp
  • e.g program.cpp
  • now press f9 to run the program
  • you have successfully built and run your 1st c++ program





  • 3.Understanding the program

lets break down the program into parts

1.#include <iostream>

This statements tells the compiler to include iostream file. This file contains pre defined input/output functions that we can use in our program.

2.Using namespace std; 
We use the namespace std to make it easier to reference operations included in that namespace.
without using namespace, we would have to write std::cout instead of cout. This tells the compiler that every cout is actually std::cout.

3.int main ()

int means iteger....this is the function from which the compiler starts executing program

4.cout <<"hello world!";

This statement is for printing “Hello World!” onto the output screen..

5.return 0;
This command tells system “The program worked fine.”



in the next post, you will get to learn about making some simple programs


C02-new line and variables


No comments:

Post a Comment