0% found this document useful (0 votes)
96 views6 pages

Repetitive Program Structure

The document provides examples of iterative program structures using flowcharts and C++ code to generate numeric series and analyze input data. It includes 8 problems that create programs to: 1) Generate 10 number series using a while loop. 2) Generate a Fibonacci series using a do-while loop. 3) Generate a number series using a do-while loop. 4) Count even and odd numbers inputted using a do-while loop. 5) Count positive and negative numbers inputted using a do-while loop. 6) Count vowels and consonants from inputted characters using validation. 7) Find the highest number from numbers inputted. 8) Calculate the average of scores

Uploaded by

Skye Jaba
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
96 views6 pages

Repetitive Program Structure

The document provides examples of iterative program structures using flowcharts and C++ code to generate numeric series and analyze input data. It includes 8 problems that create programs to: 1) Generate 10 number series using a while loop. 2) Generate a Fibonacci series using a do-while loop. 3) Generate a number series using a do-while loop. 4) Count even and odd numbers inputted using a do-while loop. 5) Count positive and negative numbers inputted using a do-while loop. 6) Count vowels and consonants from inputted characters using validation. 7) Find the highest number from numbers inputted. 8) Calculate the average of scores

Uploaded by

Skye Jaba
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Computer Fundamentals

ITERATIVE PROGRAM STRUCTURE


1.) Create a flowchart/C++ program that will generate the following number series:
10, 5, 9, 10, 8, 15, 7, 20, 6, and 25
Flowchart
Start

Declarations
num X, Y

C++ Program
#include<iostream>
using namespace std;

X = 10
Y=5

int main()
{ int X, Y;

Output X, Y

X=X1
Y=Y+5

while
X >= 6

X = 10;
Y = 5;
do
{
cout<< X<<endl<<Y<<endl;
X = X 1;
Y = Y + 5;
} while (X >= 6);
return 0;
}

N
Stop

Page 1 of 6

Computer Fundamentals
2.) Create a flowchart/C++ program that will generate the following number series:
1, 1, 2, 3, 5, 8, 13, 21, 34, and 55

Flowchart
Start

C++ Program
#include <iostream>
using namespace std;

Declarations
num X, Y, Sum

int main()
{ int X, Y, Sum;
X=0
Y=1
Sum = 1

X = 0;
Y = 1;
Sum = 1;
do
{
cout<< Sum<<endl;
Sum = X + Y;
X = Y;
Y = Sum;
} while (Sum <= 55);
return 0;
}

Output Sum
Sum = X + Y
X=Y
Y = Sum

while
Sum <= 55

N
Stop

Page 2 of 6

Computer Fundamentals
3.) Create a flowchart/C++ program that will generate the following number series:
1, 2, 4, 7, 11, 16, 22, 29, 37, and 46

Flowchart
Start

C++ Program

Declarations
num X, Y

#include <iostream>
using namespace std;
int main()
{ int X, Y;
X = 1;
Y = 1;
do
{
cout<< Y<<endl;
Y = Y + X;
X = X + 1;
} while (Y <= 46);
return 0;
}

X=1
Y=1

Output Y

Y=Y+X
X=X+1

while
Y <= 46

N
Stop

Page 3 of 6

Computer Fundamentals
4.) Create a flowchart/C++ program that will input five numbers and output how many of
the numbers entered are odd or even.
Flowchart
A

Start

ctr = ctr + 1

Declarations
Num number

while
ctr <= 5

ctr = 1
ctre = 0
ctro = 0

N
B

Output ctro, ctre

Input number

Stop
If

number % 2 == 0

ctre = ctre + 1

N
ctro = ctro + 1

C++ Program
#include <iostream>
using namespace std;
int main()
{ int num, ctr=1, ctro=0, ctre=0;
do
{
cin>> num;
if (num % 2 == 0)
ctre = ctre + 1;
else
ctro = ctro + 1;
ctr = ctr + 1;
} while (ctr <= 5);
cout<< ctro<<endl<< ctre<<endl;
return 0;
}

Page 4 of 6

Computer Fundamentals
5.) Create a flowchart/C++ program that will input five numbers and output how many of
the numbers entered are positive or negative.
Flowchart
A
Start
ctr = ctr + 1
Declarations
num number, ctr, crtp, ctrn
while
ctr <= 5

ctr = 1
ctrp =0
ctrn = 0

N
B

Output ctrp, ctrn

Input number

Stop
If
number > 0

ctrp = ctrp + 1

N
ctrn = ctrn + 1

C++ Program
#include <iostream>
using namespace std;
int main()
{
int num, ctr=1, ctrp=0, ctrn=0;
do
{
cin>> num;
if (num > 0)
ctrp = ctrp + 1;
else
ctrn = ctrn + 1;
ctr = ctr + 1;
} while (ctr <= 5);
cout<<ctrp<<endl<<ctrn<<endl;
return 0;
}

Page 5 of 6

Computer Fundamentals
6.) Create a flowchart/C++ program that will input 10 alphabetic characters and output
how many of the characters entered were vowels and consonants. Display an invalid
input message if the character entered is not alphabetic and ask the user to input a valid
character.
7.) Create a flowchart/ C++ program that will input 5 numbers and output the highest
number entered.
8.) Create a flowchart/ C++ program that will input 6 score for quizzes (0-100).
Eliminate the lowest quiz and compute and output the average of the five remaining
quizzes.

Page 6 of 6

You might also like