Lab05_sample - CMPSC 101 Introduction to Algorithmic...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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 05-1 // 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.

Page1 / 4

Lab05_sample - CMPSC 101 Introduction to Algorithmic...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online