Problem Exercises Chapter 02

Problem Exercises Chapter 02 - Problem Exercices Chapter 02...

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

View Full Document Right Arrow Icon
Problem Exercices Chapter 02 1 Problem Exercises 1. Page 148: Exercise 20. Write a C++ program that inputs a series of 10 numbers, and determines and prints the largest of the numbers. #include <iostream.h> int main() { int counter = 0, number, largest; cout << "Enter the first number: "; cin >> largest; while (++counter < 10) { cout << "Enter the next number : "; cin >> number; if (number > largest) { largest = number; } } cout << "Largest is " << largest << endl; return 0; } Sample Output :
Background image of page 1

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

View Full DocumentRight Arrow Icon
Problem Exercices Chapter 02 2 6. Page 156: Exercise 63. Write a program that uses repetition and switch structures to print the song “The Twelve Days of Christmas.” One switch structure should be used to print the day (i.e., “First,” “Second,” etc.). A separate switch structure should be used to print the remainder of each verse. #include <iostream.h> int main() { for ( int day = 1; day < 13; day++) { cout << "On the "; switch (day) { // switch for current day case 1: cout << "first";
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/27/2010 for the course DS csc 270 taught by Professor Dr.m.g during the Spring '10 term at Notre Dame University-Louaize.

Page1 / 6

Problem Exercises Chapter 02 - Problem Exercices Chapter 02...

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