0
0
C++programming~15 mins

Why C++ is widely used - See It in Action

Choose your learning style9 modes available
Why C++ is widely used
📖 Scenario: Imagine you are explaining to a friend why C++ is a popular programming language in many areas like games, software, and systems.
🎯 Goal: You will create a simple C++ program that lists some reasons why C++ is widely used.
📋 What You'll Learn
Create a list of reasons why C++ is widely used
Add a variable to count the number of reasons
Use a loop to display each reason
Print the total number of reasons at the end
💡 Why This Matters
🌍 Real World
C++ is used in many real-world applications like video games, operating systems, and high-performance software because it is fast and gives programmers control over how the computer works.
💼 Career
Knowing why C++ is popular helps beginners understand its importance and motivates learning it for careers in software development, game programming, and systems engineering.
Progress0 / 4 steps
1
Create a list of reasons
Create a std::vector<std::string> called reasons with these exact entries: "Fast performance", "Control over system resources", "Widely used in game development", "Supports object-oriented programming", "Large community and libraries".
C++
Need a hint?

Use std::vector<std::string> and initialize it with the list of reasons inside curly braces.

2
Add a counter for the number of reasons
Add an int variable called count and set it to the size of the reasons vector using reasons.size().
C++
Need a hint?

Use int count = reasons.size(); to get the number of reasons.

3
Display each reason using a loop
Use a for loop with int i = 0 to i < count to print each reason from the reasons vector using std::cout. Print each reason on its own line.
C++
Need a hint?

Use a for loop from 0 to count - 1 and print each reasons[i] with std::cout.

4
Print the total number of reasons
After the loop, print the text Total reasons: followed by the value of count using std::cout.
C++
Need a hint?

Use std::cout << "Total reasons: " << count << std::endl; to print the total count.