no solution here your code didn't work either. although much better. I seem to start with some sort of structure but I end up hacking it to make it fit, making it less user friendly.
Printable View
Here's a link to the C++ problem: Sum of Naturals divisible by 3 and 5 | Programr It only has an 11.5% success rate.
Here's another "easy" one with a low success rate (6%).
Sum of Odd Numbers | Programr
Sum all odd numbers less than or equal to a given maximum.
E.g., Given 10 the answer is 25 because 1 + 3 + 5 + 7 + 9 = 25. Given 15 the answer is 64 because 1 + 3 + 5 + 7 + 9 + 11 + 13 + 15 = 64
The code below fails.
You should report these problems. It's possible it's due to capitalization differences or something idiotic like that.Code:#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
long max = 0; //GIVEN
long sum = 0; //GIVEN
cout<<"Enter Maximum No:"; //GIVEN
cin>>max; //GIVEN
for(long i=1;i<=max;i+=2)
sum += i;
cout<<"Sum of Odd no. is:"; //GIVEN
cout<<sum<<endl;
}
Hmm, shame that seems a bit discouraging I was enjoying the site. I sent some feedback to them and will advise if I hear anything. Thanks for the help, at least their wasn't any obvious issues with my code.