hey guyz!!! i'm just trying to check my code u all if it's correct. thankz!
the problem is " ask a number (N). calculate and display the value of x, where x = (1*N)+(2*N)+(3*N)...(N*N);
ex. if i input a number 5 the formula of x where: x = (1*N)+(2*N)+(3*N)+(4*N)+(5*N);
this is my code:
#include <iostream>
int main ()
{
int n,x,y;
y=0;
cout<<"\nEnter number: ";
cin>>n;
while (y<=n)
{
cout<<"\n"<<y;
y++;
x += (y*n);
}
cout<<"\n\nx = "<<x;
return 0;
}