This is a simple C++ program that demonstrates the difference between adding two integers and concatenating two strings.
One thing to note is that the + operator behaves differently depending on the types of the variables being added. When used with integers, it performs addition. When used with strings, it performs concatenation.
#include<iostream> #include<string.h> using namespace std; int main() { int x = 10; int y = 20; int z = x+y; string a = "10"; string b = "20"; string c = a+b; cout<<"\nAddition of numbers :"<<z; cout<<"\nAddition of Strings :"<<c; return 0; }To download raw file Click Here
Addition of numbers :30 Addition of Strings :1020
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions