🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to C++ Notes
Topic #31

Numbers and Strings


Adding Numbers and Strings

Warning: WARNING! C++ uses the + operator for both addition and concatenation. Numbers are added. Strings are concatenated.

If you add two numbers, the result will be a number:

Example

int x = 10;
int y = 20;
int z = x + y;      // z will be 30 (an integer)

If you add two strings, the result will be a string concatenation:

Example

string x = "10";
string y = "20";
string z = x + y;   // z will be 1020 (a string)

If you try to add a number to a string, an error occurs:

Example

string x = "10";
int y = 20;
string z = x + y;

Want to go beyond the notes?

Join CodingNow 2.0's C++ course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

Numbers and Strings – FAQs

Quick answers about learning Numbers and Strings in C++.

This free note from CodingNow 2.0 explains Numbers and Strings in C++ — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every C++ topic on CodingNow 2.0, including Numbers and Strings, is 100% free with no signup required.
With focused practice, most students grasp Numbers and Strings in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now