w3resource

C++ programming Exercises practice with solution

What is C++ Programming Language?

C++ is a general-purpose programming language. It has imperative, object-oriented and generic programming features, while also providing facilities for low-level memory manipulation.

It was designed with a bias toward system programming and embedded, resource-constrained and large systems, with performance, efficiency and flexibility of use as its design highlights. Many vendors provide C++ compilers, including the Free Software Foundation, Microsoft, Intel, and IBM.

The best way we learn anything is by practice and exercise questions. We have started this section for those (beginner to intermediate) who are familiar with C++ programming.

Hope, these exercises help you to improve your C++ programming coding skills. Currently, following sections are available, we are working hard to add more exercises .... Happy Coding!

List of C++ Exercises

More to Come !

Popularity of Programming Language
Worldwide, Nov 2022 compared to a year ago:

`
Rank Change Language Share Trend
1 Python 28.44 % -1.2 %
2 Java 17.03 % -0.3%
3 Javascript 9.51 % +0.3%
4 C# 7.08 % -0.1%
5 C/C++ 6.51 % -0.4 %
6 PHP 5.12 % -1.0 %
7 R 4.12 % +0.4%
8 up arrow TypeScript 2.89 % +1.3%
9 down arrow Objective-C 2.17 % +0.1%
10 Swift 2.11% +0.4%
11 down arrow Go2.07% +0.7%
12 down arrow Kotlin 1.81 % +0.1%
13 up arrow Rust 1.7 % +0.6%
14 down arrow Matlab 1.58 % +0.2%
15 up arrow Ruby 1.07% +0.1%
16 down arrow VBA 0.97 % -0.2 %
17 Ada 0.81 % -0.0 %
18 up arrow Dart 0.76 % +0.3 %
19 down arrow Scala 0.73 % -0.0 %
20 up arrow Lua 0.64 % +0.2 %
21 down arrow Visual Basic 0.62 % -0.1 %
22 down arrow Abap 0.48 % -0.0 %
23 Perl 0.38 % +0.0 %
24 Groovy 0.37 % +0.0 %
25 up arrow Julia 0.3 % +0.0 %
26 up arrow Haskell 0.29 % +0.0 %
27 down arrow Cobol 0.28 % -0.1 %
28 Delphi/Pascal 0.12 % -0.1 %

Source : https://pypl.github.io/PYPL.html

TIOBE Index for November 2022

Nov 2022 Nov 2021 Change Programming Language Ratings Change
1 1 Python 17.18% +5.41%
2 2 C 15.08% +4.35%
3 3 Java 11.98% +1.26%
4 4 C++ 10.75% +2.46%
5 5 C# 4.25% -1.81%
6 6 Visual Basic 4.11% -1.61%
7 7 JavaScript 2.74% +0.08%
8 8 Assembly language 2.18% -0.34%
9 9 SQL 1.82% -0.30%
10 10 PHP 1.69% -0.12%
11 18 up arrow Go 1.15% -0.06%
12 15 up arrow R 1.14% -0.14%
13 11 down arrow Classic Visual Basic 1.10% -0.46%
14 17 up arrow Delphi/Object Pascal 1.08% -0.14
15 20 up arrow MATLAB 1.02% -0.15%
16 28 up arrow Objective-C 0.93% +0.39%
17 24 up arrow Scratch 0.88% +0.11%
18 14 up arrow Swift 0.87% -0.56%
19 13 down arrow Ruby 0.85% -0.59%
20 29 up arrow Rust 0.75% +0.21%

Source : https://www.tiobe.com/tiobe-index/



Share this Tutorial / Exercise on : Facebook and Twitter

C++ Programming: Tips of the Day

How do you clear a stringstream variable?

For all the standard library types the member function empty() is a query, not a command, i.e. it means "are you empty?" not "please throw away your contents".

The clear() member function is inherited from ios and is used to clear the error state of the stream, e.g. if a file stream has the error state set to eofbit (end-of-file), then calling clear() will set the error state back to goodbit (no error).

For clearing the contents of a stringstream, using:

m.str("");

is correct, although using:

m.str(std::string());

is technically more efficient, because you avoid invoking the std::string constructor that takes const char*. But any compiler these days should be able to generate the same code in both cases - so I would just go with whatever is more readable.

Ref: https://bit.ly/30LbMax