01.Computer programming

Computer programming is the process of writing instructions that get executed by computers.


c++ programming




There are various kinds of programming languages out there designed for various purposes.some of the popular programming languages are

c/c++
c # (known as c sharp)
Python
javascript
java
perl
swift
php
visual basic
vb.net





These programming languages can be cassified into 2 major categories.

1.Procedural programming-The procedural programming language is used to execute a sequence of statements which lead to a result


2.Object oriented programming-In oop,
the emphasis is on data rather than procedures,
the programs are divided into objects

The c++ is an example of object oriented programming.

The oop includes classes and objects,
e.g consider following part from a c++ program

int main()
{
shape circle;
circle.getdata();
circle.calculate();
return 0;
}


then the shape is class and the circle is an object under class shape.


for a clearcut explanation, watch this video

https://www.youtube.com/watch?v=70sld4fYcqU



Programming in c++ 





In linux you dont need to download any compiler.
Just right click on desktop and create an empty file and start programming. after programming, save the file with .cc extension.

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 with .cpp extension
press f9 to execute  the program



3.Understanding the program


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 ()

This is the function from which the compiler starts executing program

4.cout <<"hello world!";


cout means console out . it is the standard command used to display output.

<< is the insertion operator.

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



No comments:

Post a Comment