Prepare a c program that asks the user for an integer n and


Program: Prepare a C++ program that asks the user for an integer n and computes the sum 1^2+2^2+3^2+4^2+....+n^2 and displays it in the output screen.

You cannot use any direct formula for computation of this summation i.e you have to use loop for this. A sample output of the code will be something like this

Enter the integer n: 4

The summation is: 30

Input validation:

Do not accept a negative number. You have to use an if loop for this purpose. If the number entered is negative, finish the program displaying an error message "The value for the integer you have entered is wrong? Please run the program again"

 

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: Prepare a c program that asks the user for an integer n and
Reference No:- TGS0961253

Expected delivery within 24 Hours