0

How to add the result ? ( Description )

hai there, i have given chance to user to type in there value ( to find lucky number i first asked them to type date,and after they type date i asked them to type month number,and then for year) at last i added a code to do sum of date,month,year and let's consider the result is something like 2345 ( sum of date,month,year) and now i want a code to do sum of that 2345 up to only one digit out put ( lucky number) thank u soo much

14th Feb 2017, 4:29 PM
preeth_learner
preeth_learner - avatar
4 Answers
+ 1
I am not sure if I understood you. It might be like this: #include <iostream> /*input output lib*/ using namespace std; /*to avoid std::*/ int main() { int year,month,day; cout<<"Type a year(number): "; cin>> year; cout<<"Type a month(number): "; cin>> month; cout<<"Type a day(number): "; cin>> day; cout<<"Lucky number for this day is: "<< year+month+day " ."; return 0; }
14th Feb 2017, 4:47 PM
Roman Santa
Roman Santa - avatar
0
hai @roman yes, exactly now,please assume that you have typed all the values mine ( 25 + 03 + 1998 ) date + month + year= lucky number so after all that code and sum, i m getting 2026 ( when i add 25+03+1998 )...now what i need is the code to add 2+0+2+6 ( 2026 ) thank you soo much
14th Feb 2017, 4:50 PM
preeth_learner
preeth_learner - avatar
0
You can use vector<int>myVector() and store each int on index. I finished C and now I am newbie in new C++ features so google it and you might find the answers :) Goodluck
14th Feb 2017, 5:50 PM
Roman Santa
Roman Santa - avatar
0
thank you soo much 😍
15th Feb 2017, 2:38 AM
preeth_learner
preeth_learner - avatar