I'm making a code that will add the squares of a range, ie input number is 4,the squares of 1+ square of 2+square of 3+square of 4 (1+4+9+16)= 30.
In my code I'm using the caret symbol for the square but it just multiply the number by 2 and not squaring it.
#include<iostream>
#include<conio.h>
using namespace std;
int x,sum;
main()
{
cout<<"Enter Number: ";
cin >> x;
if(x<=0 || x>=11)
{
cout<<"WRONG INPUT\n";
}
else
{
x=x*(x^2)/2;
sum=x;
{
cout <<"SUM: "<<sum;
}
}
getch();
}