Basic C++ Program | First C++ Program

Basic C++ Program
  • Save

Hello Readers,

In this section we will cover the basics of C++, it will include the syntax, variable, data types, operators, loop types, pointers, etc., and information about other requirements of developing a simple C++ program. You will come across many terms that you have already studied C language.

Note: If one has not studied C language, no problem. You can straightaway start with C++ after reading this tutorial.

#include <iostream>

using namespace std;

int main(){

    cout<<"Hello World"<<endl;

    return 0;
}

Note: If you already know programming languages & just want to practice, click here.

Now, let’s understand the above code carefully.

Header files are included at the beginning. Here, ‘iostream‘ is a header file that provides us with input & output streams i.e., it provides us standard I/O facilities. Header files contained predefined function libraries, which can be used by users for their ease in usability.

Using namespace std tells the compiler to use namespace standard in the C++ program. Namespace collects identifiers used for class, object, and variables and it is mandatory to use namespace standards. That’s why we use namespace standard.

Example: std::cout << "A";

main(), is the function which holds the executing part of program.

Note: If you are using Dev C++ IDE, then you have to use ‘int main’. Else you may also use ‘void main’. You can choose any IDE for C++. This article might help you.

cout <<, is used to print anything on screen. cin>>  is used to take input from the user. We don’t need to specify the datatype to input variable.

If you are a beginner in programming & the above things seem a bit tough, don’t worry, things will get smooth after reading the next tutorials. Here is the index of all the topics for your reference.

Till then, Stay tuned

Leave a Reply

Your email address will not be published. Required fields are marked *

Share via
Copy link
Powered by Social Snap