C++

C++ Introduction

C++ is a programming language which is used in computer programming and mostly in game development.

What is C++?

C++ is programming language which is used in programming and mostly in game development. It was developed by Bjarne Stroustrup in 1979. It was developed to give programmers a high level of control over system resources.

Why C++?

  • C++ is a popular language which is used in operating system Graphical interface and embedded systems and it is easy to learn.
  • It is an object-oriented programming language which give a clear structure to programs and allow codes to be reused.
  • It is portable and is used to develop applications and to adapt it in multiple platforms.

What is the difference between C and C++?

C++ is a developed, enhanced and extended version of C both of them almost same syntax.

Main difference is that C++ can support classes, object but C cannot.

C++ syntax

#include <iostream>
using namespace std;
int main()
{

     cout<<“Welcome to C++”

     return 0 ;

}

Welcome to C++








In the first line #include <iostream>is our library.

  • In the second line using namespace std; means that we can use names for variables objects etc.

NOTE : Without #include <iostream> or using namespace std; your programs will not run.

  • In another line cout is used to get output and the reference of cout is <<. 
  • And in the next line is return 0 it is used to return 0 value to compiler .
  • And now } is used to close the body of program . It is necessary to close the program if you do not close it then the program will not work.
  • And in side is the output of your program given by compiler.

Points to remember

  1. It is necessary to type #include to insert library .
  2. Without using namespace std your program will not run . If you donot want to type usinge namespace std than you can type it like this  “std::cout<<” but it is nessecary to write it.
  3. You can use cout and form bodies multiple times .
  4. You can also put comments by using // (single line comment) or /* lines*/  (multi-lines comments).

Variables

What are Variables?
Variables are vessels or container which is used to store values.
C++ have different variables with different keywords such as :

  •  int- It stores numerical values such as whole numbers but it does not hold decimals.
  •  double- Stores floating value

Leave a Comment

Your email address will not be published.