+ 1

Is this code right????

#include <iostream> using namespace std; int main() { /* this code simulates the sololearn c++ course */ cout <<"what is the output of the following code :-"; cout<<"int sum=0;\n for(int i=5 ; i>=0; i--) \n { \n sum+=i; \n} \n cout <<sum;"; int x; cin>>x; if(x==15) cout<<"\n \n \n \t \t \t correct! "; else cout<<"\n \n \n \t \t \t X wrong"; return 0; }

5th Dec 2016, 8:25 AM
PROGRAMMER YOUSUF KOMOR
PROGRAMMER YOUSUF KOMOR - avatar
3 Risposte
+ 3
It is working as intended, if your input it's 15, It will say correct!
5th Dec 2016, 8:32 AM
Nahuel
Nahuel - avatar
+ 1
Is it similar to sololearn c ++ course? !?! Nahuel Ovejero
5th Dec 2016, 10:20 AM
PROGRAMMER YOUSUF KOMOR
PROGRAMMER YOUSUF KOMOR - avatar
+ 1
It's, kinda :)
5th Dec 2016, 10:27 AM
Nahuel
Nahuel - avatar