60 469
Assignments Done
98,1%
Successfully Done
In April 2018

Answer to Question #12203 in C# for Cherry blossom

Question #12203
a program that reads in a number n and then outputs the sum of squares of the numbers from 1 to n. If the input is 3, for example, the output should be 14, because 1²+2²+3² = 1+4+9=14
Expert's answer
int inp;
double res=0;
Console.WriteLine("Enter
number: ");
inp = int.Parse(Console.ReadLine());

for (int i = 0; i <= inp; i++)
{

res =
res + Math.Pow(i, 2);
}


Console.WriteLine("Result: " + res);

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions