Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
49 views

Exercise #7 - Using While and For Statements

The document provides instructions for an exercise involving the use of while and for loops in C++. Students are asked to write a program that uses a single while loop to generate numbers from 1-99 alternating between positive and negative, and uses a single for loop to input 10 random numbers and calculate the sum of the odd numbers. Students must comment their code, create flowcharts, take a screenshot of the output, and submit the source code, output, and flowcharts with the specified filenames.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views

Exercise #7 - Using While and For Statements

The document provides instructions for an exercise involving the use of while and for loops in C++. Students are asked to write a program that uses a single while loop to generate numbers from 1-99 alternating between positive and negative, and uses a single for loop to input 10 random numbers and calculate the sum of the odd numbers. Students must comment their code, create flowcharts, take a screenshot of the output, and submit the source code, output, and flowcharts with the specified filenames.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Exercise #7

Using while and for statements

Instructions:

1. Create a C++ program with the following:

Using while statement

Generate the numbers from 1 – 99 but the sequence should start with a positive number then a
negative number and so on … using a single while statement only.

Using for statement

Enter ten numbers at random and will add only the odd numbers. The sum of odd numbers will
be displayed after inputting 10 numbers. The instruction is to use a single for statement only.

Sample output screen:

2. Apply only the techniques/lessons taken from Week 2 – 13. Solutions should be within the topics
learned in the past weeks and today.

3. Place comments within your program so that we would know what is happening.
4. Create two flowcharts – one for generating odd numbers 1-99 using while statement; one for entering
ten (10) numbers at random and getting the sum of odd numbers using for statement. The flowchart will
be the basis for your checking your program. Incorrect flowchart would mean incorrect program.

5. Take a screenshot of your output file.

5. Upload the following using the indicated filenames:

Source file - [Section] LastName, FirstName_Exer7.cpp

Output file - [Section] LastName, FirstName_Exer7.jpg (or .pdf)

Flowcharts - [Section] LastName, FirstName_Exer7.pdf (or .doc/docx)

6. Follow instructions properly.

You might also like