0% found this document useful (0 votes)
5 views3 pages

CPP Programming Basics

C++ is a versatile programming language used for various applications, supporting both procedural and object-oriented programming. To start coding, one needs to install a C++ compiler and an IDE, and a simple 'Hello, World!' program is provided as an example. The document also covers variables, data types, and control flow structures like if-else statements and loops.

Uploaded by

sirvictor321
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

CPP Programming Basics

C++ is a versatile programming language used for various applications, supporting both procedural and object-oriented programming. To start coding, one needs to install a C++ compiler and an IDE, and a simple 'Hello, World!' program is provided as an example. The document also covers variables, data types, and control flow structures like if-else statements and loops.

Uploaded by

sirvictor321
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

C++ Programming Basics

C++ is a powerful general-purpose programming language. It is widely used for developing

operating systems, browsers, games, and more. C++ supports both procedural and object-oriented

programming, making it flexible and efficient.

1. Setting Up C++
To start coding in C++, install:

- A C++ compiler (e.g., GCC, MinGW)

- An IDE like Code::Blocks or Visual Studio Code

To verify installation, type `g++ --version` in your terminal or command prompt.

2. Your First C++ Program


Here is a simple C++ program that prints "Hello, World!":

```cpp

#include <iostream>

using namespace std;

int main() {

cout << "Hello, World!" << endl;

return 0;

```

To run:

1. Save as hello.cpp
2. Compile: `g++ hello.cpp -o hello`

3. Run: `./hello`

3. Variables and Data Types


C++ supports various data types:

- int: Integer numbers

- float: Floating point numbers

- char: Single characters

- string: Text (requires <string> header)

- bool: true/false

Example:

```cpp

int age = 25;

float price = 19.99;

char grade = 'A';

string name = "John";

bool isCppFun = true;

```

4. Control Flow
C++ supports if-else, switch, for, while, and do-while loops.

Example (if-else):

```cpp

int number = 10;

if(number > 0) {
cout << "Positive number" << endl;

} else {

cout << "Negative number" << endl;

```

You might also like