string concatenuation | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

string concatenuation

String a= “day”; String b=“month”; String c=“year”; Cout << a ; Cin>>x(day); Cout <<b; Cin>>y(month); Cout<<c; Cin>> z(year); I want to ask how to add string a,b,and c together but the output is the date(x/y/z) not the string?

13th Oct 2017, 5:32 AM
Anh Lam
Anh Lam - avatar
5 Answers
+ 3
simply,take a look at the code. https://code.sololearn.com/ch8JQeQarwm0/?ref=app
13th Oct 2017, 5:51 AM
Highman
Highman - avatar
+ 2
hi, an example to adapt string a="", b="",c=""; cin>>a; cin>>b; cin>>c; string date=a+"/"+b+"/"+c; cout<<date<<endl;
13th Oct 2017, 6:18 AM
MBZH31
MBZH31 - avatar
+ 2
I edited the code for getting date https://code.sololearn.com/ch8JQeQarwm0/#cpp
13th Oct 2017, 7:11 AM
Highman
Highman - avatar
0
I thought the output should be number like 04/12/2017? Sorry I am just beginner so would you mind explaining more to me?
13th Oct 2017, 6:05 AM
Anh Lam
Anh Lam - avatar
0
Here is the full task: Write the code that asks user to enter a month number (mm), day (dd), then year (yyyy) in this specific order. The program then displays the date in the format "yyyy/mm/dd". All variables should be string, not integer. Use string concatenation to create a new string that contains the whole date.
13th Oct 2017, 7:40 AM
Anh Lam
Anh Lam - avatar