Learning C++ Pr-WPS Office
Learning C++ Pr-WPS Office
Welcome to your C++ programming journey! I'll guide you from the very basics to more advanced
concepts in a structured way.
## Table of Contents
1. [Introduction to C++](#introduction)
3. [Basic Syntax](#basic-syntax)
5. [Operators](#operators)
6. [Control Structures](#control-structures)
7. [Functions](#functions)
9. [Pointers](#pointers)
- System/software development
- Game development
- Embedded systems
- High-performance applications
Key features:
- Object-oriented
- Compiled language
```cpp
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
```
```bash
./hello
```
```cpp
```
### Constants:
```cpp
```
```cpp
int a = 10, b = 3;
int sum = a + b; // 13
int diff = a - b; // 7
int prod = a * b; // 30
int quot = a / b; // 3 (integer division)
```
```cpp
```
```cpp
```
### If-Else:
```cpp
if (num > 0) {
} else {
```
### Switch:
```cpp
switch(grade) {
case 'A':
break;
case 'B':
break;
default:
```
### Loops:
**While loop:**
```cpp
int i = 0;
while (i < 5) {
i++;
// Output: 0 1 2 3 4
```
**For loop:**
```cpp
// Output: 0 1 2 3 4
```
```cpp
return a + b;
```
### Function Call:
```cpp
```
```cpp
int main() {
return 0;
// Definition
return a * b;
```
### Arrays:
```cpp
int numbers[5] = {1, 2, 3, 4, 5};
// Access elements
```
### Strings:
```cpp
#include <string>
```
```cpp
int var = 5;
```
```cpp
class Rectangle {
private:
public:
// Constructor
// Method
int area() {
}
};
```
```cpp
```
Now that you've learned the basics, here's what to explore next:
3. Exception handling
4. Templates
5. Smart pointers
6. Multithreading
#include <iostream>
#include <string>
#include <ctime>
int main() {
std::string name;
int age;
std::getline(std::cin, name);
std::cout << "Hello, " << name << "! You were born in " << birth_year << std::endl;
return 0;
```
Remember, the key to learning programming is consistent practice. Start with small programs and
gradually increase complexity. Happy coding!