03/12/2025
# # # **๐ C++ โ Introduction to Functions (With Example)**
In C++, **functions** help you write cleaner, reusable, and more organized code.
Instead of repeating the same code again and again, you write it once inside a functionโand call it whenever needed.
---
# # # โ
**Basic Structure of a C++ Function**
returnType functionName(parameters) {
// code to execute
}
```
---
# # # โ
**Example: A Simple Function in C++**
using namespace std;
// Function declaration
void greet() {
cout
19/11/2025
# # ๐ป **C++ Tutorial โ Topic 8: Switch Statement (Multiple Choices Made Easy)**
Sometimes your program needs to choose from **many options**, not just true/false.
Thatโs where the **switch statement** becomes super useful! ๐๏ธ
# # # ๐น **What is a Switch Statement?**
It lets you test **one variable** against **multiple possible values**, making your code cleaner and easier to read.
# # # ๐ก **Example: Simple Menu Program**
```cpp
using namespace std;
int main() {
int option;
cout > option;
switch(option) {
case 1:
cout
08/11/2025
Topic # 7: Level Up Your Logic โ Loops in C++ ๐
After mastering Decision Making, itโs time to make your code repeat smartly! ๐
Thatโs where loops come in โ they help you execute a block of code multiple times until a condition is met.
โจ Types of Loops in C++:
1๏ธโฃ for loop โ repeat a known number of times
2๏ธโฃ while loop โ repeat while a condition is true
3๏ธโฃ do...while loop โ executes at least once, then checks
๐ง Example:
for(int i = 1; i
06/11/2025
๐ป **C++ Tutorial โ Topic 6: Decision Making with if-else Statements**
So far, your programs can *calculate* โ but can they *think*? ๐ง
Letโs make them smart with **decision-making statements** โ using `if`, `else if`, and `else`! โก
---
# # # ๐น **What is an if-else statement?**
It lets your program **choose** what to do based on conditions.
๐ Think of it like:
โIf itโs raining, take an umbrella. Otherwise, go outside freely.โ โ
---
# # # ๐งฉ Example:
```cpp
using namespace std;
int main() {
int marks;
cout > marks;
if (marks >= 80) {
cout
05/11/2025
Shout out to my newest followers! Excited to have you onboard! Haroon Irfan Kahout King, Mueez Ahmad, M Inam Tabasum, Naqsh Lazim, Zahra Lassaci
04/11/2025
๐ป **C++ Tutorial โ Topic 5: Operators in C++**
Now that we can take input and display output,
letโs learn how to **process data** using *operators*! โ๏ธ
Operators help us perform calculations, make decisions, and manipulate data inside our programs.
---
# # # ๐น **Types of Operators**
1. **Arithmetic Operators:** `+ - * / %`
2. **Assignment Operators:** `= += -= *= /=`
3. **Comparison Operators:** `== != > < >=
03/11/2025
๐ป **C++ Tutorial โ Topic 4: Input & Output in C++**
Now that we know how to store data using variables,
letโs learn how to **communicate with the user** โ using `cin` and `cout`. ๐ฃ๏ธ๐ฌ
In C++,
* `cout` โ displays output on the screen
* `cin` โ takes input from the user
---
# # # ๐งฉ Example:
```cpp
using namespace std;
int main() {
string name;
int age;
cout > name;
cout > age;
cout
31/10/2025
๐ป C++ Tutorial โ Topic 3: Variables & Data Types
Your computer can remember things โ like your name, age, or score โ but how? ๐ค
Thatโs where variables come in!
A variable is like a labeled box ๐ฆ where your program stores information temporarily while it runs.
๐น What is a Variable?
Think of it as:
๐ง A name โ to identify it
๐พ A type โ to define what kind of data it holds
๐ฌ A value โ the actual information stored
๐น Example Code:
using namespace std;
int main() {
int age = 22; // whole number
double price = 49.99; // decimal number
char grade = 'A'; // single character
string name = "Sara"; // text
bool isHappy = true; // true or false
cout
29/10/2025
๐ป C++ Tutorial โ Topic 2: Setting Up C++ (Download & Installation Guide)
Youโve learned what programming is ๐ก
Now letโs make your computer ready to run your first C++ program! โ๏ธ
๐งฐ Step 1: Choose Your Setup Style
You can run C++ in two easy ways:
1๏ธโฃ Online (No Installation Needed)
2๏ธโฃ Offline (Install an IDE or Compiler)
Letโs see both ๐
๐ Option 1: Use an Online Compiler (Recommended for Beginners)
Perfect for learning โ no setup, no downloads!
Here are a few trusted sites:
๐น https://www.programiz.com/cpp/
๐น https://www.onlinegdb.com/
๐น https://www.jdoodle.com/c-online-compiler
How to Use:
1๏ธโฃ Open the site.
2๏ธโฃ Paste your code in the editor.
3๏ธโฃ Click Run โถ๏ธ and see the output below!
๐ก Great for mobile users or anyone learning the basics.
๐ป Option 2: Install a C++ IDE (Offline Setup)
If you want to code like a pro โ install an IDE (Integrated Development Environment).
Choose one based on your operating system:
๐ช Windows Users
โ
Option 1: Code::Blocks (Beginner Friendly)
Visit: https://www.codeblocks.org/downloads/
Download โcodeblocks-20.03mingw-setup.exeโ (includes compiler)
Install โ Open โ Create a new file โ Write your code โ Press F9 to run
โ
Option 2: Dev-C++
Download from: https://sourceforge.net/projects/orwelldevcpp/
Simple and lightweight!
๐ Mac Users
Use Xcode (from the App Store):
Search for โXcodeโ โ Install
Open Terminal โ Run:
g++ hello.cpp -o hello
/hello
Youโre good to go! ๐
๐ง Linux Users
C++ is often preinstalled!
To check, open your Terminal and type:
g++ --version
If not installed, run:
sudo apt install g++
Then compile your code:
g++ hello.cpp -o hello
/hello
๐ง Tip:
Always save your file with .cpp extension, e.g.,
๐ hello.cpp
That tells the computer itโs a C++ file.
๐ Youโre Ready!
Now your system can compile and run C++ programs.
Letโs move on to writing and understanding your first lines of code in the next topic!
JDoodle - Online Compiler, Editor for Java, C/C++, etc
JDoodle is an Online Compiler, Editor, IDE for Java, C, C++, PHP, Perl, Python, Ruby and many more. You can run your programs on the fly online, and you can save and share them with others. Quick and Easy way to compile and run programs online.
29/10/2025
๐ป C++ Tutorial โ Topic 1: Introduction to Programming
๐ Welcome to the world of Programming with C++!
Programming is simply the art of telling a computer what to do โ step by step.
C++ helps us do that efficiently and powerfully. ๐
๐น What is C++?
C++ is a high-performance, general-purpose programming language created by Bjarne Stroustrup.
Itโs used in:
๐ฎ Game development
โ๏ธ Operating systems
๐ค Artificial Intelligence
๐ผ Business software
๐น Why Learn C++?
โ
Itโs fast and efficient
โ
It teaches you how computers really work
โ
Itโs the foundation for many modern languages
๐ก Example: Your First C++ Program
using namespace std;
int main() {
cout