0

Write C++ code to accept input and add integers from 1 to 10 and print their sum.

I want the code to accept input form .. to add numbers 1-10 like 1+2+4+5+6+7+8+9+10 but I don't want to assign those addition to a variable.. I want it to be in an input form and print the sum

17th Oct 2017, 5:46 PM
focus
focus - avatar
1 Odpowiedź
- 1
#include <iostream> #include <string> using namespace std; int main() { string s; cin >> s; if(s == "1+2+3+4+5+6+7+8+9+10") cout << 55; else cout << "Wrong input."; } //Here you go, but where's the point?
21st Oct 2017, 6:58 PM
Timon Paßlick