Skip to main content

Say "Hello, World!" With C++

 Say "Hello, World!" With C++

    I recommend you install CLion IDE and start the Programming after setting up the CMake options under Build, Execution, and Deployment. CLion is a popular integrated development environment specifically designed for C++ development.

Download and Install CLion:

Download and install CLion from the official JetBrains website: https://www.jetbrains.com/clion/download/

Launch CLion:

After installation, launch CLion from your computer's application menu.

Create a New Project:

  • On the CLion welcome screen, click on "New Project."
  • Choose the "C++ Executable" template and click "Next."
  • Enter a name for your project and choose a location to save it. Click "Create."

Configure CMake:

  • CLion uses CMake to manage your project's build configuration.
  • CLion will generate a CMakeLists.txt file for you.
  • You can customize CMake settings in the "CMakeLists.txt" file as needed.

Write Your C++ Code:

  • In the project window, you'll see the "src" folder. Right-click on it and select "New" > "C++ Source File."
  • Enter a name for your source file (e.g., "main.cpp") and click "OK."
  • CLion will open the newly created source file in the editor.

Write and Run Your Program:

  • Write your C++ code in the editor. For example, you can start with a simple "Hello, World!" program.
  • After writing the code, you can build and run it by clicking the green "Run" button on the top toolbar or pressing Shift + F10.

//My First C++ Program
#include <iostream>

int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}

View Output:

The output of your program will be displayed in the "Run" tool window at the bottom of the CLion interface.


Debugging:

CLion offers powerful debugging features. You can set breakpoints, inspect variables, and step through your code to diagnose issues.


Working of C++ "Hello World!" Program

//My First C++ Program
#include <iostream>

int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}

// Your First C++ Program

In C++, any line starting with // is a comment. Comments are intended for the person reading the code to better understand the functionality of the program. It is completely ignored by the C++ compiler.


#include <iostream>

The #include is a preprocessor directive used to include files in our program. The above code is including the contents of the iostream file.

This allows us to use cout in our program to print output on the screen.

For now, just remember that we need to use #include <iostream> to use cout that allows us to print output on the screen.


int main() {...}

A valid C++ program must have the main() function. The curly braces indicate the start and the end of the function.

The execution of code beings from this function.


std::cout << "Hello World!";

std::cout prints the content inside the quotation marks. It must be followed by << followed by the format string. In our example, "Hello World!" is the format string.


Note: ; is used to indicate the end of a statement.


return 0;

The return 0; statement is the "Exit status" of the program. In simple terms, the program ends with this statement.

Remember that C++ development involves learning the language syntax, concepts, and best practices. You can use online resources, tutorials, and courses to enhance your C++ programming skills. As you become more comfortable with CLion and C++, you can start working on more complex projects and exploring advanced features of the IDE.

Prepared by: Malinda Gamage -> LinkedIn Profile






Comments

Popular posts from this blog

Unraveling the Apache Hadoop Ecosystem: The Ultimate Guide to Big Data Processing πŸŒπŸ’ΎπŸš€

In the era of big data, organizations are constantly seeking efficient ways to manage, process, and analyze large volumes of structured and unstructured data. Enter Apache Hadoop , an open-source framework that provides scalable, reliable, and distributed computing solutions. With its rich ecosystem of tools, Hadoop has become a cornerstone for big data projects. Let’s explore the various components and layers of the Hadoop ecosystem and how they work together to deliver insights. Data Processing Layer πŸ› ️πŸ” The heart of Hadoop lies in its data processing capabilities, powered by several essential tools: Apache Pig 🐷 : Allows Hadoop users to write complex MapReduce transformations using a scripting language called Pig Latin , which translates to MapReduce and executes efficiently on large datasets. Apache Hive 🐝 : Provides a SQL-like query language called HiveQL for summarizing, querying, and analyzing data stored in Hadoop’s HDFS or compatible systems like Amazon S3. It makes inter...

Understanding Cloud Computing: SaaS, PaaS, IaaS, and DaaS Explained ☁️πŸ’»πŸš€

 In today’s digital world, cloud computing has revolutionized the way businesses and individuals store, access, and manage data and applications. From reducing the burden of software management to providing scalable platforms for app development, the cloud offers a wide range of services tailored to different needs. Let’s dive into the most common cloud services: SaaS, PaaS, IaaS, and DaaS . 1. SaaS – Software as a Service πŸ–₯️✨ SaaS is the most recognizable form of cloud service for everyday consumers. It takes care of managing software and its deployment, making life easier for businesses by removing the need for technical teams to handle installations, updates, and licensing. πŸ”‘ Key Benefits : Cost Reduction : No need for a dedicated IT team or expensive licensing fees. Ease of Use : Access software directly through the internet without complex setup. πŸ› ️ Popular SaaS Applications : Salesforce : A leading CRM platform that helps businesses manage customer relationships. Google ...

Springboot Simple Project - Student Results Management System

My project is a Student Results Management System . It involves managing students and their results for different subjects. The key components of my project are: Entities : Student and Result Repositories : Interfaces for data access Services : Business logic layer Controllers : REST APIs for handling HTTP requests Configuration : Database and other configurations 1. Entities Entities represent the tables in your database. Let's look at your entities and understand the annotations used. Student Entity : Annotations : @Entity : Marks the class as a JPA entity. @Table(name = "students") : Specifies the table name in the database. @Id : Denotes the primary key. @GeneratedValue(strategy = GenerationType.IDENTITY) : Specifies the generation strategy for the primary key. @OneToMany(mappedBy = "student", cascade = CascadeType.ALL, orphanRemoval = true) : Defines a one-to-many relationship with the Result entity. The mappedBy attribute indicates that the student fiel...