DEV Community

Mehfila A Parkkulthil
Mehfila A Parkkulthil

Posted on • Edited on

Day 1 : C++ language | Introduction

Hey everyone!
I'm excited to announce that I'm starting a blog series focused on Data Structures and Algorithms (DSA). I'll be sharing tutorials based on what I've learned and know.
I'll be using the C++ language for these tutorials, and I'll also be posting C++ language tutorials for those who are new to it.


C++ is a powerful, high-performance programming language that is widely used for system/software development, game development, and in applications requiring real-time processing.

It is an extension of the C programming language, adding object-oriented features and others.


Basics

C++ extension pack

Folder path


Basics of C++

  • Code editor we are using here is Visual studio code.
  • The extension of c++ is .cpp .

Syntax of C++

#include <iostream>
using namespace std;

int main() {

      }
Enter fullscreen mode Exit fullscreen mode

Syntax


How the code works

*How to write code *

Anything written inside the curly brackets is gonna be executed .
ie,
For example : To print "Hello world " , the word that has to be printed inside quotation marks.

#include <iostream>
using namespace std;

int main() {

cout << "Hello world" << endl;
return 0;

      }
Enter fullscreen mode Exit fullscreen mode

first print


How to run code

  • To run a C++ file, you'll need to have MinGW installed.
  • Open new terminal in vscode .
  • Type g++ filename.cpp - o filename ./filename.exe
  • Then enter.
\\ for windows users

g++ myfirstfile.cpp - o myfirstfile
./myfirstfile.exe

Enter fullscreen mode Exit fullscreen mode

Terminal


Explanation of code

  • #include <iostream>: This line includes the input-output stream library, which is necessary for performing input and output operations.

  • using namespace std : You are informing the compiler that you are going to use the std (standard) namespace, so you don't need to prefix standard library entities with std::. And both works well .

Example:
namespace

  • ; - Every statement must end with a semicolon , it basically tells the compiler this line ends here ( same feature of fullstop . in english language).

  • int main(): This line defines the main function, which is the starting point of the program. Every C++ program must have a main function.

  • { }: These curly braces is the body of the main function, where the code to be executed is written .

  • cout(read as c-out) : is used to output data (or print) .

  • The << operator is used to insert the data into the output stream.

  • "Hello, World!" is the string_(long form of text)_ that will be displayed on the console area .

  • endl - Used to insert a newline, moving the cursor to the next line.

  • return 0-This line indicates that the program has successfully executed and returns 0 to the calling process or operating system ( means has executed successfully without any errors or zero errors).

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more