C++ Programming Basics Part 1

ChicaTechHub
2 min readJun 27, 2024

--

C++ PROGRAMMING

Grasp the big picture and build strong foundation

we’ll walk you through the basic skeleton of a C++ program and the essential components you need to know to get started.

The general skeleton of C++ program has two main components:

1. Library inclusion

2. Main Function

  1. Library inclusion:

C++ relies on libraries to access various functionalities

For example if you want to get input from user then you need to use the library called #include<iostream>. To perform math functions you need to use #include<math.h>

2. Main Function:

This is the entry point of your program

After including the necessary libraries, you declare the main function

Code:

#include<iostream>

int main(){

// write your logic here

return 0;

}

Then you have cout function to display the output

example:

std:: <<cout<<”ChicaTechHub”;

you’ll commonly use the cout function from the iostream library. However, you need to specify that it belongs to std (standard) namespace.

Line Break:

  1. \n : This is a simple escape sequence that inserts a newline character.This method is faster than std::endl because performs low-level operation that directly moves the cursor to the beginning of the next line in the output
  2. std::endl: insert a newline character

code:

#include<iostream>

int main(){

std:: cout <<ChicaTechHub << std::endl;

}

3.using namespace std: By adding using namespace std; at the beginning of your program, you’re telling the compiler that you want to use all the names from the std namespace without explicitly specifying std:: each time.

code:

#include<iostream>

using namespace std;

int main(){

std:: cout <<ChicaTechHub << :endl;

}

To get more content like this follow

https://www.youtube.com/@chicatechhub

https://www.instagram.com/chicatechhub/

Thank you for Reading…

--

--