C++ Program to Find Largest Number Among Three Numbers
Finds max of three.
#include <iostream>
int main(){
int a=5,b=17,c=9;
int m=a; if(b>m)m=b; if(c>m)m=c;
std::cout << "Largest = " << m << std::endl;
return 0;
}Largest = 17
Key takeaway: Practice C++ with 63+ runnable code examples — I/O, loops, math, strings, arrays, pointers, classes, and operator overloading — all with expected output to verify your understanding.
C++ is a general-purpose, object-oriented programming language used for game engines, system software, embedded devices, and high-performance applications. These examples are for CS students, interview candidates, and developers building C++ skills.
Last updated: October 2026 · 63 examples · All platforms
Who is this for: CS students, game dev learners, competitive programmers, and job seekers preparing for C++ interviews. Use this when: you need verified C++ reference code or practice problem solutions.
Related:Online C++ Compiler · C++ Tutorial · C Examples
Finds max of three.
#include <iostream>
int main(){
int a=5,b=17,c=9;
int m=a; if(b>m)m=b; if(c>m)m=c;
std::cout << "Largest = " << m << std::endl;
return 0;
}Largest = 17
Average of array values.
#include <iostream>
int main(){
int a[]={2,4,6,8,10}; int n=5; int s=0;
for(int i=0;i<n;i++) s+=a[i];
std::cout << "Average = " << (double)s/n << std::endl;
return 0;
}Average = 6
Finds max element.
#include <iostream>
int main(){
int a[]={3,9,2,7,5}; int n=5; int m=a[0];
for(int i=1;i<n;i++) if(a[i]>m) m=a[i];
std::cout << "Largest = " << m << std::endl;
return 0;
}Largest = 9
Traverses array via pointers.
#include <iostream>
int main(){
int a[]={10,20,30,40}, n=4; int* p=a;
for(int i=0;i<n;i++) std::cout << *(p+i) << ' ';
std::cout << std::endl;
return 0;
}10 20 30 40
Array of structures.
#include <iostream>
#include <string>
struct Student{ std::string name; int age; };
int main(){
Student s[2]={{"Ann",19},{"Bob",21}};
std::cout << s[0].name << ' ' << s[0].age << "\n" << s[1].name << ' ' << s[1].age << std::endl;
return 0;
}Ann 19 Bob 21
g++ program.cpp -std=c++17 -O2 -o program && ./program. Or use our free online C++ compiler. -std=c++17 flag when compiling. Who is this for: Multiple audiences across industries and experience levels:
Use this when: you need verified reference code, want to complete an assignment, prepare for interviews, or warm up before a systems/game project. Best for beginners through intermediate-level programmers.
The TIOBE Index ranked C++ as #2 in 2024. It powers:
C++ roles pay $120K–$200K+ in these industries.
| Feature | C++ | C |
|---|---|---|
| OOP | Classes, inheritance, polymorphism | No |
| STL | vector, map, set, algorithms | Manual arrays |
| Memory | new/delete + smart pointers | malloc/free |
| Strings | std::string | char arrays |
| Errors | try/catch exceptions | Error codes |
Related:C++ Tutorial · Online C++ Compiler · C Examples
Direct answer: C++ developers work in high-performance computing, game development, finance, embedded systems, and infrastructure. Key roles include:
Absolutely yes. C++ is one of the highest-paying programming languages because the jobs that require it are technically demanding and mission-critical. While there are fewer C++ jobs than JavaScript or Python jobs in raw count, C++ positions pay 20–40% more on average because the supply of skilled C++ developers is much smaller than demand. According to the StackOverflow 2024 Survey, C++ developers rank among the top 5 highest-paid globally.
| Experience | India (LPA) | USA (USD/year) | Typical Role |
|---|---|---|---|
| Fresher (0–1 yr) | ₹5–10 LPA | $70,000–$100,000 | Junior Developer |
| Mid (3–5 yrs) | ₹15–30 LPA | $120,000–$160,000 | Software Engineer |
| Senior (5–10 yrs) | ₹30–60 LPA | $160,000–$250,000 | Senior/Staff Engineer |
| Quant/HFT | ₹50–1.5 Cr | $200,000–$500,000+ | Quantitative Developer |
Yes, but you'll need complementary skills. C++ alone gets you interviews, but companies also expect: data structures & algorithms (essential for all C++ roles), one domain specialization (game dev, embedded, finance), familiarity with build tools (CMake, Make), and version control (Git). For embedded roles, add hardware knowledge. For game dev, add linear algebra and a game engine. For finance, add math/statistics.
Top employers by category:
Timeline:
Total: 9–12 months of consistent daily practice (2–3 hours/day) to be job-ready for entry-level C++ positions.
Yes, significantly. C++ has manual memory management, pointers, templates, multiple inheritance, undefined behavior, and a complex compilation model. Python abstracts all of this away. However, learning C++ first makes you a stronger programmer overall because you understand what's happening "under the hood." Developers who know C++ find Python trivially easy to learn later — the reverse is much harder.
Core interview topics:
No. Entry-level positions expect you to know: basic syntax, OOP, pointers, STL basics, and solve medium-level DSA problems in C++. You don't need to understand template metaprogramming, SFINAE, or write lock-free code for your first job. That comes with experience. Focus on: clean code, correct memory management, and problem-solving ability.
| Language | Avg Salary (US) | Avg Salary (India) | Job Availability |
|---|---|---|---|
| C++ | $135,000 | ₹18 LPA | Moderate (niche) |
| Python | $120,000 | ₹12 LPA | Very High |
| Java | $115,000 | ₹14 LPA | High |
| Rust | $140,000 | ₹20 LPA | Low (growing) |
| Go | $130,000 | ₹16 LPA | Moderate |
C++ pays more per role because the jobs are harder and candidates are fewer. HFT (high-frequency trading) C++ roles are the highest-paid programming jobs in the world.
Top 10 skills from job postings (2025–2026):
Yes, but it's harder. C++ is not the friendliest first language — Python or JavaScript are easier starting points. However, many CS programs teach C++ as the first language (IITs, NITs use C/C++ in first year). If you're disciplined and willing to struggle with pointers and memory for the first 2 months, you can absolutely learn C++ from scratch. Use the examples on this page to practice — they start from Hello World and build up gradually.
Growing in specialized domains. While web development moved to JavaScript/Python, C++ demand is increasing in: electric vehicles (autonomous driving), AI inference (TensorRT, ONNX Runtime are C++), gaming (Unreal Engine 5), HFT (latency-critical trading), and edge computing. The TIOBE Index shows C++ consistently in top 3. Companies are hiring more C++ developers for performance-critical workloads as software becomes more latency-sensitive.
| Industry | Use Case | Example Companies |
|---|---|---|
| Gaming | Game engines, physics, rendering | Epic, EA, Ubisoft |
| Finance/HFT | Low-latency trading, risk engines | Citadel, Tower, DE Shaw |
| Automotive | Self-driving, ADAS, ECU firmware | Tesla, Waymo, Bosch |
| Big Tech | Browsers, databases, OS | Google, Microsoft, Meta |
| Aerospace | Flight systems, simulation | Boeing, Lockheed, ISRO |
| AI/ML Infrastructure | Inference engines, GPU kernels | NVIDIA, OpenAI, Google |
Honest assessment: C++ is one of the hardest mainstream languages to learn. The difficulty comes from: manual memory management (no garbage collector), undefined behavior (code that compiles but crashes), template syntax (notoriously ugly), and the language having 40+ years of features stacked on top of each other. However, you don't need to learn ALL of C++ — modern C++ (C++17/20) is cleaner, and you can be productive knowing ~30% of the language features. Focus on STL, smart pointers, RAII, and basic templates.
new but forgetting delete — use smart pointers insteadstd::vector is faster and safer-Wall -Werror)malloc/printf instead of new/cout, raw arrays instead of vectorYes — increasingly common post-2020. Game development, finance (quant roles), and Big Tech infrastructure teams offer remote C++ positions. Embedded roles are harder to do remotely (need hardware access), though some companies ship dev kits to remote workers. Remote C++ salaries are often 80–100% of on-site pay at major companies. Platforms like LinkedIn, Indeed, and Turing.com list remote C++ positions globally.
Sources: StackOverflow Developer Survey 2024, TIOBE Index, LinkedIn Job Postings 2024–2025, Glassdoor salary data. Practice C++ with the examples above — each runs directly in your browser.