LoopsHomework - COSC1415/COSC1436 Loops Homework Page 1 of...

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

View Full Document Right Arrow Icon
COSC1415/COSC1436 Loops Homework Page 1 of 2 Name Chintu Patel 8001 COSC1415/COSC1436 - Homework Objectives: At the end of this homework you should be able to: 1. use a switch statement 2. convert a while loop to a do-while loop 3. convert a do-while loop to a while loop 4. convert a while loop to a for loop 5. convert a for loop to a while loop 6. convert a for loop to a do-while loop Homework Part A: From the C++ compiler create a new project (called Counting ) and Add Exisitng Item ( Counting.cpp copied from eCampus to your storage device). a. Debug the program so that the code will count the number of each type of punctuation mark in the file. b. Compile and run the program c. Add the code that also counts blank spaces. Print a copy of the program and a copy of its output. Homework Part B: Make sure that the sample output includes loop termination. 1. Create a new project. Add New Item and type the following code segment. Declare variables as needed. Run the program to make sure it gives correct output. Now rewrite the loop using a do-while loop instead of a while loop. You should not have any unnecessary code in your program. When your modified program produces the same result, print the program and sample output . cout << “Enter 1, 2, or 3: ”; << endl; cin >> response; while (response != 1 && response != 2 && response != 3) { cout << “Enter 1, 2, or 3: “; << endl; cin >> response; } 2. Create a new project. Add New Item and type the following code segment. Declare variables as needed. Run the program to make sure it gives correct output. Now rewrite the loop using a while loop instead of a do-while loop. When your modified program produces the same
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/06/2008 for the course COSC 1436 taught by Professor May during the Spring '08 term at Dallas Colleges.

Page1 / 14

LoopsHomework - COSC1415/COSC1436 Loops Homework Page 1 of...

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

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