This preview shows pages 1–3. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: CMPSC 101 Introduction to Algorithmic Processes Summer 2007 LAB 5 – Loop Control List Headed by Size 1. Write a program that sums a sequence of integers. Assume that the first integer read with cin specifies the number of values remaining to be entered. Your program should read only one vale each time cin is executed. A typical input sequence might be 5 100 200 50 25 300 where the 5 indicates that the subsequent 5 value are to be summed // File name: Lab05_01.cpp // Description: sums a sequence of integers // Lab 051 // Author: Jaehyun Lim // Date: Thursday, July 5, 2007 #include <iostream> using namespace std; int main() { int number_of_values, input, sum=0; cout << "How many numbers do you want to enter? " << endl; cin >> number_of_values; cout << "Plese enter a number one at a time" << endl; for ( int counter=1; counter <= number_of_values; counter++) { cin >> input; sum += input; } cout << "Your total is " << sum << endl; return 0; } 2. [text p.176] An approximate value of pi (π) can be calculated using the series given [text p....
View
Full
Document
This note was uploaded on 07/14/2008 for the course CMPSC 101 taught by Professor Drobish,renee during the Summer '07 term at Pennsylvania State University, University Park.
 Summer '07
 DROBISH,RENEE

Click to edit the document details