Assignment_5

# Assignment_5 - order You must use a while loop that...

This preview shows page 1. Sign up to view the full content.

Computer Science G175 – C++ Programming Assignment 5 Assignment_5_1.cpp (1 point) Write a program that accepts an integer and adds the square of all integers from 1 to the number entered. Make sure to use a loop… For instance if 4 is entered, your program should compute 1 + 2*2 + 3*3 + 4*4 = 30. Your program should display the result, 30 with this example. Assignment_5_2.cpp (1 point) Write a program that takes an integer input from the user and breaks it down into its components (its digits). The program should accept the integer using cin. Assume the number entered by the user will be positive and will not start with a zero. For example, if the user enters the number 12345 then the program should display: 5 4 3 2 1 This is the original number broken down into its component digits and displayed in reverse
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: order. You must use a while() loop that performs integer division and modulus operations on the number entered by the user. (This type of algorithm can be used to convert from decimal to another base: for instance if you use 8 instead of 10 with the integer division and modulus, you will convert from decimal to octal, but displayed in reverse…) You'll get 1 point for each of these assignments and they are due as per our website. In addition to these labs, also review the Word document “Session 5” that has been posted to the website. Please refer to our textbook, chapter “Lesson 7” for additional information. Page 1 of 1...
View Full Document

## This note was uploaded on 12/07/2010 for the course CS 175 taught by Professor Mike during the Spring '06 term at Golden West College.

Ask a homework question - tutors are online