๐๐ฅ๐๐ ๐ ๐ฎ๐๐๐ฒ๐ฟ๐ฐ๐น๐ฎ๐๐ ๐ข๐ป ๐๐ฎ๐๐ฒ๐๐ ๐ง๐ฒ๐ฐ๐ต๐ป๐ผ๐น๐ผ๐ด๐ถ๐ฒ๐ ๐
Get the 90-Day Plan to Build 1% Tech Career
- AI
- GenAI
- Data Analytics
- Fullstack
- UI/UX
Use Coupon Code " ๐๐๐๐๐จ๐ฉ๐๐ญ๐ฌ๐ฌ " To Register For FREE
๐ฅ๐ฒ๐ด๐ถ๐๐๐ฒ๐ฟ ๐๐ผ๐ฟ ๐๐ฅ๐๐๐ :-
https://pdlink.in/4fFMe22
Date:- 21st Nov 2026 Time:- 5:00 PM (IST)
Get the 90-Day Plan to Build 1% Tech Career
- AI
- GenAI
- Data Analytics
- Fullstack
- UI/UX
Use Coupon Code " ๐๐๐๐๐จ๐ฉ๐๐ญ๐ฌ๐ฌ " To Register For FREE
๐ฅ๐ฒ๐ด๐ถ๐๐๐ฒ๐ฟ ๐๐ผ๐ฟ ๐๐ฅ๐๐๐ :-
https://pdlink.in/4fFMe22
Date:- 21st Nov 2026 Time:- 5:00 PM (IST)
๐๐ข๐ข๐ฆ๐ง ๐ฌ๐ข๐จ๐ฅ ๐ฅ๐๐ฆ๐จ๐ ๐ ๐ช๐๐ง๐ ๐ฐ ๐๐ฅ๐๐ ๐๐ก-๐๐๐ ๐๐ก๐ ๐๐ข๐จ๐ฅ๐ฆ๐๐ฆ! ๐
๐ Want to learn high-demand tech skills without spending โน1?
๐ Data Analytics
๐ป Full Stack Development
๐ค AI & Generative AI
โ๏ธ Cloud Computing
๐ฏPerfect for Students, Freshers & Job Seekers!
๐๐ถ๐ป๐ธ๐:-
https://pdlink.in/4jsqetS
๐ SAVE & SHARE with friends looking for FREE courses๐ฅ
๐ Want to learn high-demand tech skills without spending โน1?
๐ Data Analytics
๐ป Full Stack Development
๐ค AI & Generative AI
โ๏ธ Cloud Computing
๐ฏPerfect for Students, Freshers & Job Seekers!
๐๐ถ๐ป๐ธ๐:-
https://pdlink.in/4jsqetS
๐ SAVE & SHARE with friends looking for FREE courses๐ฅ
๐๐๐ฆ๐๐ข ๐๐ฅ๐๐ ๐๐ข๐จ๐ฅ๐ฆ๐๐ฆ ๐ฎ๐ฌ๐ฎ๐ฒ! ๐
Boost your Resume & LinkedIn Profile with valuable tech skills
Explore FREE Cisco learning resources! ๐
๐ Networking Fundamentals
๐ Cybersecurity
โ๏ธ Cloud & DevOps
๐ป IT Fundamentals
๐ฏ Perfect for Students, Freshers & Job Seekers!
๐๐ถ๐ป๐ธ๐:-
https://pdlink.in/3WPl0Qg
๐ SAVE & SHARE with friends interested in Tech Careers! ๐ฅ
Boost your Resume & LinkedIn Profile with valuable tech skills
Explore FREE Cisco learning resources! ๐
๐ Networking Fundamentals
๐ Cybersecurity
โ๏ธ Cloud & DevOps
๐ป IT Fundamentals
๐ฏ Perfect for Students, Freshers & Job Seekers!
๐๐ถ๐ป๐ธ๐:-
https://pdlink.in/3WPl0Qg
๐ SAVE & SHARE with friends interested in Tech Careers! ๐ฅ
โค2
๐ ๐ง๐ข๐ฃ ๐ฐ ๐๐ฅ๐๐ ๐๐๐ฉ๐ข๐ฃ๐ฆ ๐๐ข๐จ๐ฅ๐ฆ๐๐ฆ ๐ฎ๐ฌ๐ฎ๐ฒ! โ๏ธ
๐ Explore 4 FREE learning resources to build valuable DevOps skills!
โ Beginner-Friendly Resources
โ Learn at Your Own Pace
โ Build In-Demand Technical Skills
๐ฏ Perfect for Students, Freshers & Aspiring DevOps Engineers!
๐๐ถ๐ป๐ธ๐:-
https://pdlink.in/3WKDbGO
๐ SAVE & SHARE with friends interested in DevOps careers! ๐ฅ
๐ Explore 4 FREE learning resources to build valuable DevOps skills!
โ Beginner-Friendly Resources
โ Learn at Your Own Pace
โ Build In-Demand Technical Skills
๐ฏ Perfect for Students, Freshers & Aspiring DevOps Engineers!
๐๐ถ๐ป๐ธ๐:-
https://pdlink.in/3WKDbGO
๐ SAVE & SHARE with friends interested in DevOps careers! ๐ฅ
๐๐ป๐๐ฒ๐ฟ๐๐ถ๐ฒ๐๐ฒ๐ฟ:
You have 2 minutes to solve this SQL query.
Find the customers who placed orders on three or more consecutive days.
Assume the table structure:
orders(order_id, customer_id, order_date)
๐ ๐ฒ: Challenge accepted! ๐ช
WITH consecutive_orders AS (
SELECT
customer_id,
order_date,
DATE_SUB(
order_date,
INTERVAL ROW_NUMBER() OVER (
PARTITION BY customer_id
ORDER BY order_date
) DAY
) AS grp
FROM (
SELECT DISTINCT
customer_id,
order_date
FROM orders
) t
)
SELECT
customer_id
FROM consecutive_orders
GROUP BY
customer_id,
grp
HAVING COUNT(*) >= 3;
๐ก Explanation:
This query identifies sequences of consecutive order dates for each customer.
โข ROW_NUMBER() assigns a sequence number to each order date per customer.
โข Subtracting the row number from the order date creates the same grp value for consecutive dates.
โข GROUP BY customer_id, grp groups each consecutive streak.
โข **HAVING COUNT(*) >= 3** returns customers with a streak of at least three consecutive days.
This question tests your understanding of: Common Table Expressions (CTEs), Window Functions (ROW_NUMBER()), Gaps and Islands Problem, Date Arithmetic.
๐ฏ Expected Output Example
Customer ID
101
205
(Customer 101 ordered on June 1, 2, and 3. Customer 205 ordered on July 10, 11, and 12.)
๐ Tip for SQL Job Seekers:
The Gaps and Islands pattern is one of the most advanced and frequently discussed SQL interview topics.
Master it for solving:
โข Consecutive login days
โข Consecutive purchases
โข Attendance streaks
โข Consecutive transactions
โข User activity analysis
Being comfortable with this pattern can set you apart in technical interviews.
โค๏ธ React with โค๏ธ for more SQL interview challenges!
You have 2 minutes to solve this SQL query.
Find the customers who placed orders on three or more consecutive days.
Assume the table structure:
orders(order_id, customer_id, order_date)
๐ ๐ฒ: Challenge accepted! ๐ช
WITH consecutive_orders AS (
SELECT
customer_id,
order_date,
DATE_SUB(
order_date,
INTERVAL ROW_NUMBER() OVER (
PARTITION BY customer_id
ORDER BY order_date
) DAY
) AS grp
FROM (
SELECT DISTINCT
customer_id,
order_date
FROM orders
) t
)
SELECT
customer_id
FROM consecutive_orders
GROUP BY
customer_id,
grp
HAVING COUNT(*) >= 3;
๐ก Explanation:
This query identifies sequences of consecutive order dates for each customer.
โข ROW_NUMBER() assigns a sequence number to each order date per customer.
โข Subtracting the row number from the order date creates the same grp value for consecutive dates.
โข GROUP BY customer_id, grp groups each consecutive streak.
โข **HAVING COUNT(*) >= 3** returns customers with a streak of at least three consecutive days.
This question tests your understanding of: Common Table Expressions (CTEs), Window Functions (ROW_NUMBER()), Gaps and Islands Problem, Date Arithmetic.
๐ฏ Expected Output Example
Customer ID
101
205
(Customer 101 ordered on June 1, 2, and 3. Customer 205 ordered on July 10, 11, and 12.)
๐ Tip for SQL Job Seekers:
The Gaps and Islands pattern is one of the most advanced and frequently discussed SQL interview topics.
Master it for solving:
โข Consecutive login days
โข Consecutive purchases
โข Attendance streaks
โข Consecutive transactions
โข User activity analysis
Being comfortable with this pattern can set you apart in technical interviews.
โค๏ธ React with โค๏ธ for more SQL interview challenges!
โค4
๐ง๐ข๐ฃ ๐ฑ ๐๐ฅ๐๐ ๐ฅ๐๐ฆ๐ข๐จ๐ฅ๐๐๐ฆ ๐ง๐ข ๐ ๐๐ฆ๐ง๐๐ฅ ๐ฆ๐ค๐! ๐
Discover 5 FREE learning resources to make SQL easier to understand!
โ SQL Basics & Queries
โ Joins & Subqueries
โ GROUP BY & Window Functions
โ Hands-On SQL Practice
โ Interview Preparation
๐ฏ Perfect for Students, Freshers & Aspiring Data Analysts!
๐๐ถ๐ป๐ธ๐:-
https://pdlink.in/4CoB4J2
๐ SAVE & SHARE with friends learning SQL! ๐ฅ
Discover 5 FREE learning resources to make SQL easier to understand!
โ SQL Basics & Queries
โ Joins & Subqueries
โ GROUP BY & Window Functions
โ Hands-On SQL Practice
โ Interview Preparation
๐ฏ Perfect for Students, Freshers & Aspiring Data Analysts!
๐๐ถ๐ป๐ธ๐:-
https://pdlink.in/4CoB4J2
๐ SAVE & SHARE with friends learning SQL! ๐ฅ
๐ ๐๐ป๐ฑ๐ถ๐ฎ ๐๐ ๐ข๐ฝ๐ฒ๐ป | ๐ง๐๐ฟ๐ป ๐๐ผ๐๐ฟ ๐๐ ๐๐ธ๐ถ๐น๐น๐ ๐ถ๐ป๐๐ผ ๐ฎ ๐ฐ๐ฎ๐ฟ๐ฒ๐ฒ๐ฟ ๐ผ๐ฝ๐ฝ๐ผ๐ฟ๐๐๐ป๐ถ๐๐๐
Internships paying up to โน1 lakh/month and full-time roles offering up to โน50 LPA.
๐ โน50,000 for first place ยท โน1.2 lakh in total cash prizes across the top 20
๐ 12โ13 December ยท Round 1 test and interview
๐ฅ๐ฒ๐ด๐ถ๐๐๐ฒ๐ฟ ๐๐ผ๐ฟ ๐๐ฅ๐๐ ๐:-
https://pdlink.in/4APQjZN
๐ Save the dates and share this with a friend whoโs building with AI.
Internships paying up to โน1 lakh/month and full-time roles offering up to โน50 LPA.
๐ โน50,000 for first place ยท โน1.2 lakh in total cash prizes across the top 20
๐ 12โ13 December ยท Round 1 test and interview
๐ฅ๐ฒ๐ด๐ถ๐๐๐ฒ๐ฟ ๐๐ผ๐ฟ ๐๐ฅ๐๐ ๐:-
https://pdlink.in/4APQjZN
๐ Save the dates and share this with a friend whoโs building with AI.
๐ How to Choose Your Development Path ๐จโ๐ป๐ฅ
Programming is a huge field.
Trying to learn everything at once leads to confusion and burnout.
Instead, choose one path, master it, build projects, and become an expert.
๐ง Why Choosing a Path is Important
Many beginners make this mistake:
โ Python today
โ Web Development tomorrow
โ AI next week
โ Cybersecurity next month
Result: Learned many things, Mastered nothing
The better approach is:
โข Choose One Path
โข Learn Deeply
โข Build Projects
โข Get Experience
โข Get Hired
๐ PATH 1: Web Development
Web Developers build websites and web applications.
Everything you use online is built by web developers.
Examples: E-commerce Websites, Social Media Platforms, Banking Portals, Learning Platforms, Business Websites
๐ง What You'll Learn
Frontend Development Frontend is what users see.
Learn: HTML, CSS, JavaScript, React
Backend Development Backend handles business logic and databases.
Learn: Node.js, Express.js, Django
Databases Learn: MySQL, PostgreSQL, MongoDB
๐ Technologies React, Node.js, Django, MongoDB
๐ Example Projects Portfolio Website, Blog Application, E-commerce Website, Chat Application, Food Delivery Platform
๐ผ Career Roles Frontend Developer, Backend Developer, Full Stack Developer, Software Engineer
๐ PATH 2: Data Science & AI
If you love data, statistics, automation, and intelligent systems, this path is for you.
AI is transforming industries worldwide.
๐ง What You'll Learn
Data Analysis Learn: Excel, SQL, Python, Data Visualization
Machine Learning Learn: Regression, Classification, Clustering
Deep Learning Learn: Neural Networks, Computer Vision, NLP
๐ Technologies Pandas, NumPy, Scikit-learn, TensorFlow
๐ Example Projects Sales Dashboard, Recommendation System, Sentiment Analysis, AI Chatbot, Stock Prediction Model
๐ผ Career Roles Data Analyst, Data Scientist, Machine Learning Engineer, AI Engineer
๐ฑ PATH 3: App Development
App Developers build mobile applications.
Examples: WhatsApp, Instagram, Uber, Paytm
๐ง What You'll Learn
Android Development Learn: Kotlin, Android Studio
Cross-Platform Development Learn: Flutter, React Native
APIs & Databases Learn: REST APIs, Firebase, MySQL
๐ Technologies Flutter, React Native, Kotlin
๐ Example Projects Expense Tracker App, Food Ordering App, Fitness Tracker, Chat App, E-learning App
๐ผ Career Roles Android Developer, iOS Developer, Mobile App Developer
โ๏ธ PATH 4: Cloud & DevOps
Cloud and DevOps professionals manage deployment and infrastructure.
They ensure applications run smoothly at scale.
๐ง Learn Linux, Networking Basics, Docker, Kubernetes, AWS
๐ Technologies Docker, AWS, Kubernetes
๐ผ Career Roles DevOps Engineer, Cloud Engineer, Site Reliability Engineer
๐ PATH 5: Cybersecurity
Cybersecurity professionals protect systems from attacks.
With increasing cyber threats, demand is growing rapidly.
๐ง Learn Networking, Linux, Ethical Hacking, Penetration Testing, Security Tools
๐ Technologies Kali Linux, Wireshark
Programming is a huge field.
Trying to learn everything at once leads to confusion and burnout.
Instead, choose one path, master it, build projects, and become an expert.
๐ง Why Choosing a Path is Important
Many beginners make this mistake:
โ Python today
โ Web Development tomorrow
โ AI next week
โ Cybersecurity next month
Result: Learned many things, Mastered nothing
The better approach is:
โข Choose One Path
โข Learn Deeply
โข Build Projects
โข Get Experience
โข Get Hired
๐ PATH 1: Web Development
Web Developers build websites and web applications.
Everything you use online is built by web developers.
Examples: E-commerce Websites, Social Media Platforms, Banking Portals, Learning Platforms, Business Websites
๐ง What You'll Learn
Frontend Development Frontend is what users see.
Learn: HTML, CSS, JavaScript, React
Backend Development Backend handles business logic and databases.
Learn: Node.js, Express.js, Django
Databases Learn: MySQL, PostgreSQL, MongoDB
๐ Technologies React, Node.js, Django, MongoDB
๐ Example Projects Portfolio Website, Blog Application, E-commerce Website, Chat Application, Food Delivery Platform
๐ผ Career Roles Frontend Developer, Backend Developer, Full Stack Developer, Software Engineer
๐ PATH 2: Data Science & AI
If you love data, statistics, automation, and intelligent systems, this path is for you.
AI is transforming industries worldwide.
๐ง What You'll Learn
Data Analysis Learn: Excel, SQL, Python, Data Visualization
Machine Learning Learn: Regression, Classification, Clustering
Deep Learning Learn: Neural Networks, Computer Vision, NLP
๐ Technologies Pandas, NumPy, Scikit-learn, TensorFlow
๐ Example Projects Sales Dashboard, Recommendation System, Sentiment Analysis, AI Chatbot, Stock Prediction Model
๐ผ Career Roles Data Analyst, Data Scientist, Machine Learning Engineer, AI Engineer
๐ฑ PATH 3: App Development
App Developers build mobile applications.
Examples: WhatsApp, Instagram, Uber, Paytm
๐ง What You'll Learn
Android Development Learn: Kotlin, Android Studio
Cross-Platform Development Learn: Flutter, React Native
APIs & Databases Learn: REST APIs, Firebase, MySQL
๐ Technologies Flutter, React Native, Kotlin
๐ Example Projects Expense Tracker App, Food Ordering App, Fitness Tracker, Chat App, E-learning App
๐ผ Career Roles Android Developer, iOS Developer, Mobile App Developer
โ๏ธ PATH 4: Cloud & DevOps
Cloud and DevOps professionals manage deployment and infrastructure.
They ensure applications run smoothly at scale.
๐ง Learn Linux, Networking Basics, Docker, Kubernetes, AWS
๐ Technologies Docker, AWS, Kubernetes
๐ผ Career Roles DevOps Engineer, Cloud Engineer, Site Reliability Engineer
๐ PATH 5: Cybersecurity
Cybersecurity professionals protect systems from attacks.
With increasing cyber threats, demand is growing rapidly.
๐ง Learn Networking, Linux, Ethical Hacking, Penetration Testing, Security Tools
๐ Technologies Kali Linux, Wireshark
โค3
๐ผ Career Roles Security Analyst, Penetration Tester, Security Engineer
๐ฎ PATH 6: Game Development
For those passionate about games.
๐ง Learn C#, Unity, Unreal Engine
๐ Technologies Unity, Unreal Engine
๐ผ Career Roles Game Developer, Gameplay Programmer, Graphics Programmer
๐ How to Choose the Right Path
Ask yourself:
Do you enjoy building websites ๐ Choose Web Development
Do you enjoy data and analytics ๐ Choose Data Science & AI
Do you enjoy mobile apps ๐ Choose App Development
Do you enjoy servers and infrastructure ๐ Choose Cloud & DevOps
Do you enjoy security and hacking ๐ Choose Cybersecurity
Do you enjoy games ๐ Choose Game Development
๐ฅ Most Beginner-Friendly Paths
1๏ธโฃ Web Development
2๏ธโฃ Data Analytics / Data Science
3๏ธโฃ App Development
These paths have abundant learning resources, projects, and job opportunities.
โ ๏ธ Common Mistakes
โ Following trends blindly
โ Switching paths every month
โ Learning multiple domains simultaneously
โ Avoiding projects
๐ Final Advice
Your first path does not have to be your last path.
Many professionals start as: Web Developer to AI Engineer, Data Analyst to Data Scientist, App Developer to Full Stack Developer
The important thing is to pick one path and commit to it.
Focus > Consistency > Projects > Experience > Success
๐ Double Tap โค๏ธ For More
๐ฎ PATH 6: Game Development
For those passionate about games.
๐ง Learn C#, Unity, Unreal Engine
๐ Technologies Unity, Unreal Engine
๐ผ Career Roles Game Developer, Gameplay Programmer, Graphics Programmer
๐ How to Choose the Right Path
Ask yourself:
Do you enjoy building websites ๐ Choose Web Development
Do you enjoy data and analytics ๐ Choose Data Science & AI
Do you enjoy mobile apps ๐ Choose App Development
Do you enjoy servers and infrastructure ๐ Choose Cloud & DevOps
Do you enjoy security and hacking ๐ Choose Cybersecurity
Do you enjoy games ๐ Choose Game Development
๐ฅ Most Beginner-Friendly Paths
1๏ธโฃ Web Development
2๏ธโฃ Data Analytics / Data Science
3๏ธโฃ App Development
These paths have abundant learning resources, projects, and job opportunities.
โ ๏ธ Common Mistakes
โ Following trends blindly
โ Switching paths every month
โ Learning multiple domains simultaneously
โ Avoiding projects
๐ Final Advice
Your first path does not have to be your last path.
Many professionals start as: Web Developer to AI Engineer, Data Analyst to Data Scientist, App Developer to Full Stack Developer
The important thing is to pick one path and commit to it.
Focus > Consistency > Projects > Experience > Success
๐ Double Tap โค๏ธ For More
โค7
๐ง๐ข๐ฃ ๐ฏ ๐๐ฅ๐๐ ๐๐๐ฅ๐ง๐๐๐๐๐๐ง๐๐ข๐ก๐ฆ ๐๐ก ๐๐๐ง๐ ๐ฆ๐๐๐๐ก๐๐ & ๐๐ก๐๐๐ฌ๐ง๐๐๐ฆ! ๐
Kick-start your career in Data Science or Data Analytics
โ Build In-Demand Technical Skills
โ Strengthen Your Resume
โ Explore Certification Opportunities
๐ฏ Perfect for Students, Freshers & Aspiring Data Analysts!
๐๐ถ๐ป๐ธ๐:-
https://pdlink.in/4g3OYGL
๐ SAVE & SHARE with your friends! ๐ฅ
Kick-start your career in Data Science or Data Analytics
โ Build In-Demand Technical Skills
โ Strengthen Your Resume
โ Explore Certification Opportunities
๐ฏ Perfect for Students, Freshers & Aspiring Data Analysts!
๐๐ถ๐ป๐ธ๐:-
https://pdlink.in/4g3OYGL
๐ SAVE & SHARE with your friends! ๐ฅ
๐ฏ ๐๐ฟ๐ฒ๐ฒ ๐๐ผ๐๐ฟ๐๐ฒ๐ ๐๐ผ ๐๐ฒ๐๐ฒ๐น ๐จ๐ฝ ๐ฌ๐ผ๐๐ฟ ๐ง๐ฒ๐ฐ๐ต ๐ฆ๐ธ๐ถ๐น๐น๐ ๐ถ๐ป ๐ฎ๐ฌ๐ฎ๐ณ๐
Want to upgrade your technical skills without spending โน1?
โ Learn In-Demand Tech Skills
โ Strengthen Your Resume
โ Boost Your Career Prospects
๐ฏ Perfect for Students, Freshers & Working Professionals!
๐๐ถ๐ป๐ธ๐:-
https://pdlink.in/4jsqp7k
๐ SAVE & SHARE with your friends! ๐ฅ
Want to upgrade your technical skills without spending โน1?
โ Learn In-Demand Tech Skills
โ Strengthen Your Resume
โ Boost Your Career Prospects
๐ฏ Perfect for Students, Freshers & Working Professionals!
๐๐ถ๐ป๐ธ๐:-
https://pdlink.in/4jsqp7k
๐ SAVE & SHARE with your friends! ๐ฅ
๐ ๐ง๐ผ๐ฝ ๐๐ป-๐๐ฒ๐บ๐ฎ๐ป๐ฑ ๐๐ฒ๐ฟ๐๐ถ๐ณ๐ถ๐ฐ๐ฎ๐๐ถ๐ผ๐ป๐ ๐๐ผ ๐ ๐ฎ๐๐๐ฒ๐ฟ ๐ถ๐ป ๐ฎ๐ฌ๐ฎ๐ฒ
Explore these certification courses in todayโs most in-demand technology fields:
๐ป Full Stack :- https://pdlink.in/3SuUeuD
๐ Data Analytics :- https://pdlink.in/45vk5ph
๐ซAI Engineering :- https://pdlink.in/4fWJVID
๐ฅ Take the first step towards your high-paying tech career in 2026!
Explore these certification courses in todayโs most in-demand technology fields:
๐ป Full Stack :- https://pdlink.in/3SuUeuD
๐ Data Analytics :- https://pdlink.in/45vk5ph
๐ซAI Engineering :- https://pdlink.in/4fWJVID
๐ฅ Take the first step towards your high-paying tech career in 2026!
๐ C++ Learning Series - Part 3: Functions in C++
Functions are one of the most important concepts in C++ programming.
A function is a reusable block of code designed to perform a specific task.
Instead of writing the same code repeatedly, you can create a function and call it whenever needed.
1. Function Declaration
A function declaration tells the compiler about the function name, return type, and parameters before the function is used.
Syntax:
Example:
Output:
2. Function Definition
A function definition contains the actual code that executes when the function is called.
Here:
โข
โข
โข
3. Function Calling
A function call executes the statements inside a function.
Output:
4. Function Parameters
Parameters are variables that receive values when a function is called.
Output:
Here,
5. Return Values
A function can return a value using the
Output:
6. Pass by Value
In pass by value, a copy of the variable is passed to the function.
Changes made inside the function do not affect the original variable.
Output:
7. Pass by Reference
In pass by reference, the function receives a reference to the original variable.
Changes made inside the function affect the original variable.
Output:
8. Default Arguments
Default arguments allow you to assign default values to function parameters.
If an argument is not provided during the function call, the default value is used.
Output:
You can also override the default value:
9. Function Overloading
Function overloading allows multiple functions to have the same name but different parameter lists.
Output:
Functions are one of the most important concepts in C++ programming.
A function is a reusable block of code designed to perform a specific task.
Instead of writing the same code repeatedly, you can create a function and call it whenever needed.
1. Function Declaration
A function declaration tells the compiler about the function name, return type, and parameters before the function is used.
Syntax:
return_type function_name(parameters);
Example:
#include <iostream>
using namespace std;
void greet();
int main() {
greet();
return 0;
}
void greet() {
cout << "Hello, Welcome to C++!";
}
Output:
Hello, Welcome to C++!
2. Function Definition
A function definition contains the actual code that executes when the function is called.
void display() {
cout << "Learning C++ Functions";
}Here:
โข
void represents the return type.โข
display is the function name.โข
{ } contains the function body.3. Function Calling
A function call executes the statements inside a function.
void message() {
cout << "Hello World!";
}
int main() {
message();
return 0;
}Output:
Hello World!
4. Function Parameters
Parameters are variables that receive values when a function is called.
void greet(string name) {
cout << "Hello " << name;
}
int main() {
greet("John");
return 0;
}Output:
Hello John
Here,
name is a parameter and "John" is the argument passed to the function.5. Return Values
A function can return a value using the
return statement.int add(int a, int b) {
return a + b;
}
int main() {
int result = add(10, 20);
cout << result;
return 0;
}Output:
30
6. Pass by Value
In pass by value, a copy of the variable is passed to the function.
Changes made inside the function do not affect the original variable.
void change(int x) {
x = 100;
}
int main() {
int number = 50;
change(number);
cout << number;
return 0;
}Output:
50
7. Pass by Reference
In pass by reference, the function receives a reference to the original variable.
Changes made inside the function affect the original variable.
void change(int &x) {
x = 100;
}
int main() {
int number = 50;
change(number);
cout << number;
return 0;
}Output:
100
8. Default Arguments
Default arguments allow you to assign default values to function parameters.
If an argument is not provided during the function call, the default value is used.
void greet(string name = "Guest") {
cout << "Hello " << name;
}
int main() {
greet();
return 0;
}Output:
Hello Guest
You can also override the default value:
greet("John");9. Function Overloading
Function overloading allows multiple functions to have the same name but different parameter lists.
int add(int a, int b) {
return a + b;
}
int add(int a, int b, int c) {
return a + b + c;
}
int main() {
cout << add(10, 20) << endl;
cout << add(10, 20, 30);
return 0;
}Output:
30
60
The compiler selects the appropriate function based on the arguments.
10. Recursion
Recursion occurs when a function calls itself to solve a problem.
Every recursive function should have a base condition to stop further calls.
Example: Factorial using recursion
int factorial(int n) {
if (n == 0 || n == 1) {
return 1;
}
return n * factorial(n - 1);
}
int main() {
cout << factorial(5);
return 0;
}Output:
120
Explanation:
factorial(5)
= 5 * factorial(4)
= 5 * 4 * factorial(3)
= 5 * 4 * 3 * factorial(2)
= 5 * 4 * 3 * 2 * factorial(1)
= 120
11. Inline Functions
An inline function suggests that the compiler replace a function call with the function's code where appropriate.
inline int square(int n) {
return n * n;
}
int main() {
cout << square(5);
return 0;
}Output:
25
The
inline keyword is a request to the compiler, not a guarantee that the function will be expanded inline.12. Lambda Functions
Lambda functions are anonymous functions that can be defined directly inside an expression.
They are useful when you need a small function without declaring a separate named function.
int main() {
auto greet = []() {
cout << "Hello from Lambda!";
};
greet();
return 0;
}Output:
Hello from Lambda!
Lambda with parameters:
auto add = [](int a, int b) {
return a + b;
};
cout << add(10, 20);Double Tap โค๏ธ For Part-4