I'm trying to solve a problem that my friend gave me and i'm really stuck at it, I'm solving this now for about 1 whole day and my PC's about to melt.
Im trying to figure out how to add numbers in a range i.e I input the number 6 and it will give me the sum of 21 because 1+2+3+4+5+6 = 21,Number limit is 10
Im using DevC++ as Compiler.
Here's my code, it suck's cause it just multiplies the input by 2.
#include<iostream>
#include<conio.h>
using namespace std;
int x,y,sum;
main()
{
cout<<"Enter Number:";
cin >> x;
if(x<=0 || x>=11)
{
cout<<"WRONG INPUT\n";
}
else
{
for(y=1;y<=x;y++)
sum=y+x;
{
cout << sum ;
}
}
getch();
}