Welcome to C++ programming

Welcome to C++ programming

INTRODUCTION

C++ is completely free and readily available on all platforms  and easy to understand.

Follow the steps  below for you to run C++ on your computer.

1. You need to download a compiler and install it in your pc you can download DEV -C++ {https://filehippo.com/download_dev-c/} this will work best

2. If you want a quick start, you can also run C++ program online with your phone or pc.  online compiler

How the program works?

The code is divided into six major parts check the code below:

/******************************************************************************
 C++ PROGRAM TO PRINT HELLO, ENGINEERS 
AUTOR: ORENGO DICKSON
EGERTON UNIVERSITY.
DATE: 11TH. 5. 2019
*******************************************************************************/
#include <iostream>  
using namespace std;
int main()
{
std::cout << "Hello Engineers!\n" << std::endl
return 0;
}
  1. #include <iostream>
  1. If you’ve already written code in C language before, you might seen this line of code before {#include <stdio.h>}. If you haven’t, don’t worry we’ll cover it now for better understanding.

2. This statement includes the header file into the application so that you are able to use the operations included in them. Also, you can create your own header files and include them in your program using the #include.

What is iostream? 

  1. iostream is what you call the header file. It is a standard C++ input/output library file.
  2. It comes packaged with the compiler/IDE (integrated development environment. ) and contain mechanisms to get the information from the user and print same or added information to a file, screen or any other media.

What is #include? 

  1. The #include iostream file, into the program. This ensures that now you’re able to use the operations, iostream operations (like: taking input from user, displaying output on the screen), in the program.

What is using namespace std;”?

  1. The statement is intuitive in itself, you are “using” the “namespace” “std” in your file.
  2. We use the namespace std to make it easier to reference operations included in that namespace.
  3. If we hadn’t used the namespace, we’d have written std::cout instead of cout. This tells the compiler that every cout is actually std::cout.

What’s a namespace?

  1. It’s a region where your code resides. It limits or expands the scope of your code to one or more files.

Why do you use namespace?

  1. Like two persons can have the same name, variables and functions in C++ can have same names as well. The use of namespace is to avoid the confusion of which variables/functions you are referencing to.

What is std?

  1. std is a standard namespace used in C++.

Semicolon ”;”

  1. Ask any C++ programmer and they will tell you at least one horror story related to the semicolon ; .
  2. The semicolon is a terminal. It terminates a statement. When missed or incorrectly used, it will cause a lot of issues.

int main() { }

  1. As the name suggests, it is the main function of the program. The code inside { } is called the body and is executed first when you run your C++ program.
  2. It is one code that is mandatory in a C++ program. If you just have this line of code alone, your program will be valid.

cout << “Hello World!”;

  1. This statement prints “Hello World!” onto the output screen.
  2. The cout is an object of standard output stream. What this means is, it outputs/prints the data after << , i.e. Hello World! into a stream (in this case, the output screen).

What is a stream?

  1. Stream is basically a sequence of objects, usually bytes. It can describe files, input/output terminal, sockets, etc.

What is <<?

  1. << is the insertion operator used to write formatted data into the stream.

What is return 0;?

  1. This statement returns 0 ‘zero’.
  2. This is called a return statement. It isn’t mandatory to return anything from the main() function but is rather a convention. If not return, the compiler returns a status automatically.

Why zero in return statement?

  1. It denotes Exit status of the application that basically the tells system “The program worked fine.”


Thanks for visiting our website!

????

One Reply to “Welcome to C++ programming”

  1. It¦s really a cool and helpful piece of info. I¦m happy that you simply shared this helpful information with us. Please stay us informed like this. Thanks for sharing.

Leave a Reply

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