1. Nmap and Nmap History
  2. Working In a High School As A Computer Instructor
  3. Penetration Testing Jobs in worldwide – A Valuable Online Resource
  4. Types of computer software
  5. Cross-site scripting (XSS) attack
  6. Five Best Cyber Security and Ethical Hacking Private Degrees in Sri Lanka
  7. Google’s open-source tsunami vulnerability scanner
  8. What is Google? (Tutorial)
  9. What is a SQL Injection Attack?
  10. Is WordPress Easy?
  11. How to find a perfect domain name for your website (10+ Tips and Tricks Tutorial)
  12. 6 new vulnerabilities with D-Link home routers allow hackers to launch remote attacks
  13. What is the YouTube and YouTube AdSense?
  14. C++ Lesson 6 – Storage of information through user interactions and VARIABLES
  15. How to get full root Access by Termux without Root?
  16. Trojan horse’s Story | who is this Trojan horse
  17. Don’t use these wallpapers in your mobile phone – System Crash wallpaper issue
  18. Burp Suite pro [Professional 2020.4.1]
  19. Website SEO checker tool
  20. What is DNS? (Domain Name System)
  21. C++ Lesson 5 – Get ready for the first program – Part 2
  22. Whatsapp Secrets Code List
  23. Python Lesson 1 – Python and Computer Programming
  24. C++ Lesson 4 – Get ready for the first program
  25. C++ Lesson 3 – Setting the background PROGRAMMING for LINUX.
  26. What is an Email? (Learn about Email)
  27. GoDaddy reveals a data breach, exposing the credentials of the web hosting account
  28. C++ Lesson 2: Setting the PROGRAMMING Background for WINDOWS
  29. C++ full tutorial | How to start C++ | Part 001
  30. What is the IP Address? – Full Tutorial
  31. How to install Kali Linux in windows Computer using virtualBox – 001
  32. Online YouTube Backlink Generator Tool
  33. How to use ShellPhish in mobile phone – Advance Phishing tool
  34. Remote Command Execution (R.C.E) vulnerability
  35. Mobile phone Ethical Hacking & Penetration Testing platform (Termux)
  36. Nmap network scanning (Basic Tutorial for Beginers) – 002
  37. Nmap Port Scanning tool (Basic Tutorial for Beginers) – 001
  38. Penetration Testing and Ethical Hacking Linux Distribute – Kali Linux
  1. Nmap and Nmap History
  2. Working In a High School As A Computer Instructor
  3. Penetration Testing Jobs in worldwide – A Valuable Online Resource
  4. Types of computer software
  5. Cross-site scripting (XSS) attack
  6. Five Best Cyber Security and Ethical Hacking Private Degrees in Sri Lanka
  7. Google’s open-source tsunami vulnerability scanner
  8. What is Google? (Tutorial)
  9. What is a SQL Injection Attack?
  10. Is WordPress Easy?
  11. How to find a perfect domain name for your website (10+ Tips and Tricks Tutorial)
  12. 6 new vulnerabilities with D-Link home routers allow hackers to launch remote attacks
  13. What is the YouTube and YouTube AdSense?
  14. C++ Lesson 6 – Storage of information through user interactions and VARIABLES
  15. How to get full root Access by Termux without Root?
  16. Trojan horse’s Story | who is this Trojan horse
  17. Don’t use these wallpapers in your mobile phone – System Crash wallpaper issue
  18. Burp Suite pro [Professional 2020.4.1]
  19. Website SEO checker tool
  20. What is DNS? (Domain Name System)
  21. C++ Lesson 5 – Get ready for the first program – Part 2
  22. Whatsapp Secrets Code List
  23. Python Lesson 1 – Python and Computer Programming
  24. C++ Lesson 4 – Get ready for the first program
  25. C++ Lesson 3 – Setting the background PROGRAMMING for LINUX.
  26. What is an Email? (Learn about Email)
  27. GoDaddy reveals a data breach, exposing the credentials of the web hosting account
  28. C++ Lesson 2: Setting the PROGRAMMING Background for WINDOWS
  29. C++ full tutorial | How to start C++ | Part 001
  30. What is the IP Address? – Full Tutorial
  31. How to install Kali Linux in windows Computer using virtualBox – 001
  32. Online YouTube Backlink Generator Tool
  33. How to use ShellPhish in mobile phone – Advance Phishing tool
  34. Remote Command Execution (R.C.E) vulnerability
  35. Mobile phone Ethical Hacking & Penetration Testing platform (Termux)
  36. Nmap network scanning (Basic Tutorial for Beginers) – 002
  37. Nmap Port Scanning tool (Basic Tutorial for Beginers) – 001
  38. Penetration Testing and Ethical Hacking Linux Distribute – Kali Linux
C++ Lesson 4 – Get ready for the first program
C++ Lesson 4 - Get ready for the first program

If you haven’t studied our C++ lessons yet, look below.

C++ full tutorial | How to start C++ | Part 001

C++ Lesson 2: Setting the PROGRAMMING Background for WINDOWS

C++ Lesson 3 – Setting the background PROGRAMMING for LINUX.

I think lessons learned in the past have made your computer’s development environment. This means that you are already able to create and run a program.

In this lesson I hope to talk about these things, we know that when we create a program, we have to write the source codes. This source code is writing using that vocabulary. So let’s talk about some of the recurring concepts in this vocabulary and how a program is structure by the main function and how to add comments to a program. And a little guide on how to think likes a programmer.

Let’s start with a simple program.

This is a very simple program and we cannot see any output in this.

int main ()

{

}

Let’s see what the first line does here.

int main ()

Basically this means that there is a function and its name is main. And this main function is the only function in a C++ program. Another thing is when you run the program that starts with this main function.

Curly braces { }

 Display the start and end points of the program. You may think this is the beginning and end of the program. Likewise, there is nothing between the two braces and the function means nothing. This means that when you run this program, you will not get any output. Well, now let’s go a little further.

#include <iostream>

using namespace std;
int main ()
{
      cout << “HEY, you, I’m SecDevi.com, and Hello World!\n”;
}

First of all, as you can see, this program has a line between two braces. This means that this program has an output.

ALSO READ  C++ Lesson 6 - Storage of information through user interactions and VARIABLES

Let’s start with the first line.

#include <iostream>

This statement includes tells our compiler to add a header file called iostream to the source code before running the program. These header files are part of the code provided with the compiler. In the Borland compiler, these files are located in the Include folder. #include Using this command we can add the whole header file to our source code. It is therefore through these header files that we add functions to our program.

Whenever we want to access the functions, the first thing we need to do is to include the header file with the corresponding functions in our source code. iostream is a header file which has many functions. So you can look at these included statements and what we do.

The line behind the include statement is:

Using namespace std;

This is calling the boilerplate code. This is including in every C++ program. Remember, this is exactly what you want below the statement includes at the top of the source code. We’ll talk about it later exactly what happens with the boilerplate code. Then add this line immediately without forgetting.

And see, at the end of this line, a semicolon has been added. Adding a semicolon is part of the C++ programming syntax. This semicolon is use to tell the compiler where an instruction ends. One of the biggest mistakes made by most new programmers is forgetting to apply this semicolon. So if your program isn’t working properly, the first thing to see is how to apply the semicolon correctly.

ALSO READ  C++ Lesson 5 – Get ready for the first program - Part 2

Well, then we have the main function, which is where the program starts:

int main ()

This is our next line.

cout << “HEY, you, I’m SecDevi.com, and Hello World!\n”;

In C++, the cout object is use to display text. We have included the iostream header file to use this cout.

In the cout object we use the << symbol to show our output. In short, the result of this (cout <<) is to present a function or a line of text. There are some programming cases that we cannot give a correct idea in Sinhala because if they do, they will change their mentality. I can’t even explain it in English because it’s programming in Sinhala. So I hope you understand this.

We usually call the result of a function like this as an argument. These functions take arguments for that function from its code. In this case you see that this argument string is the function argument.

“Text” – This is where the compiler cites the text string as output here. The next important one is this newline sequence (\n).

Newline sequence (\n) – Works in C++ as a single character. This is basically like when you press the Enter key, the cursor will move to the next line.

And as you can see, in the future we will use a special value called endl. This is exactly what happens if you give an example:

cost << “Hello” << endl

cost << “Hello \n”

As you can see, the first line I used is the value of end1 and the new line is replace by the new line character. We will talk about their further use.

ALSO READ  C++ Lesson 3 - Setting the background PROGRAMMING for LINUX.

And at the end of the line, you see, I used a semicolon. We need to apply this semicolon as a function.

At the end you have to close the function using the brace. You should definitely run this program and not copy and paste this little program. Because it helps you get to know the little things better.

So don’t just run this program, you can change it and see what other lines are use. Thinking & Speaking is the best way to learn a language, so Thinking & Executing is the best way to learn a programming language.

What happens if your program is not displayed?

Depending on the operating system and the compiler you are using, what happens if you run a program that flashes before the program gets close enough to see the result? If you use the environments I explained to you in the previous lessons, you won’t get this problem, but if you run a different program, you can run into this problem. You can solve it by adding this line to the program.

cin.get();

This is exactly the end of the program. This will keep the program from closing until you press a button. So you can take care of the result.

Tags: , , , , , , , , , , , , , , ,
Thiwanga Sandaruwan is a professional blog writer. SecDevil.com is the main website of he managed. If you have any problem feel free and contact him.

Related Article

Leave a Reply

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

CommentLuv badge