Master C++ programming with our comprehensive tutorial. Learn through examples and hands-on practice.
C++ is a powerful general-purpose programming language that extends C with object-oriented features.
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!" << endl;
return 0;
}
A simple Hello World program in C++
Learn the fundamental syntax and structure of C++ programs including variables, data types, and operators.
int number = 42;
double pi = 3.14159;
char grade = 'A';
bool isValid = true;
string name = "John";
Common data types and variable declarations
// Arithmetic operators
int sum = a + b;
int difference = a - b;
int product = a * b;
int quotient = a / b;
int remainder = a % b;
Basic arithmetic operators in C++
Control structures allow you to control the flow of program execution.
// If-else statement
if (score >= 90) {
cout << "Grade A";
} else if (score >= 80) {
cout << "Grade B";
} else {
cout << "Grade C";
}
// For loop
for (int i = 0; i < 5; i++) {
cout << i << " ";
}
// While loop
while (condition) {
// code block
}
Common control structures in C++