Computes the sum and displays it

Assignment Help C/C++ Programming
Reference no: EM13707988

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"

 

Reference no: EM13707988

Questions Cloud

Make a hangman game using the given parts : Make a Hangman game using the given parts
Write a program that creates an array of 200 random numbers : Write a program that creates an array of 200 random real numbers between 0 and 200.  Using the statistics library, calculate and output the following: mean, median, variance, standard deviation, maximum value, and minimum value.
Write a program that creates an array of 200 random numbers : Write a program that creates an array of 200 random real numbers between 0 and 200.  Using the statistics library, calculate and output the following: mean, median, variance, standard deviation, maximum value, and minimum value.
Difference between cyber-related crimes and cyber crimes : Summarize the difference between cyber-related crimes and cyber crimes. On cyber crimes, define cyber trespass, cyber vandalism and cyber privacy. On cyber-related crimes describe the difference between cyber-assisted and cyber-enhanced crimes.
Computes the sum and displays it : 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.
Prepare the function reverseit : Prepare the function reverseit that reverses the characters in a character array. You must also write main that calls reverseit.
Create an array dynamically : Write a program to accept a number representing how many first names the user will enter from the command line (5 names maximum), and the actual first names, from the command line.
Explain what is the partial pressure of n2 in this vessel : What is the partial pressure of SO2 in the larger container. What is the partial pressure of N2 in this vessel. What is the total pressure in the vessel
Define the concentration of a particular species in a sample : Problem- If you wanted to measure the concentration of a particular species in a sample, describe the procedure you would use to do so.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Describe how an element in an array is accessed in memory

Describe how an element in an array is accessed in memory. For example, where is myArray[25] stored in memory?

  Dynamically allocates an array large enough

Write a program that dynamically allocates an array large enough to hold a number of test score. The size of the array should be input by the user

  For the employee class make

For the Employee class make sure that no person is underage or too old (less than 16 or greater than 80). Do nothing for the set function if the person's age is out of range.

  Create a c++ console application

Objective: Create a C++ console application that will model the characteristics of a resistor. Create a multifile project. Create and add to the project an h file containing the resistor-class definition. Create and add to the project a cpp file cont..

  Write an application that shows the sum

This is for Object-Oriented Programming Using C++ language - Edition Joyce Farrell. Please ensure to read everything that I have wrote so that there is no confusion.

  You are to create a program

You are to create a program that will input a group of floating point values, storing them as double values in an array. This array will then be sent to three functions.

  Develop a program that displays random numbers

Using a timer to generate a random number, develop a program that displays random numbers between 1 and 47 for your state's lottery.

  Writing a program that creates a linked list

Writing a program that creates a linked list from 100 randomly generated numbers and sorts the using a heap. One heap in ascending order and one heap in descending order. Then displays the original linked list and both sorted lists.

  Create a program that outputs the result of the formula

Create a program that outputs the result of the formula f = (a - b)(x - y) using the printf() functions.

  Add a sentinel command to stop the loop

add a sentinel command to stop the loop. When the program is compiled, It'll ask the user to type in a palindrome. I want the user to type EXIT to end the loop.

  Generates a random number and asks the user

Write a program in c++ that generates a random number and asks the user to guess what the number is. If the user's guess is higher than the random number

  Determine frequency of each character found in the array

Determines the frequency of each character found in the array - array of pointers to strings and the number of strings as arguments

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd