Professional Documents
Culture Documents
Flowcharts and Algorithms Final
Flowcharts and Algorithms Final
If Input
Input i<=9?
T num
l,w
F
area=l*w A
If
num==0 zero=zero+1
peri=2*(l+w) ? T
zero
F
area, peri
A If
num%2= even=even+1
3
0? T
area=PI*radius*radius
area
A
4
T
If Input If positive=positive+1
i<=9? num num>0?
T
F
F
If negative=negative+1
num<0?
T
zero=zero+1
5
Input
input1
min=input1
min max i++
If If
counter Input min=input
input
<=1? input
T <min? T
F F
A
If max=input
5 num<0?
T
Input F
Run
If T
Run==’n’ || A
Run==’N’?
F
B
Algorithm:
1. Start.
2. Initialize float arr[10], store=0. and int i=0, j=0.
3. for (i=0;i<=9;i++). then enter arr[i].
4. for (i=0;i<=9;i++), then for (int j=0;j<=9;j++).
If (arr[i]<arr[j]), then
store=arr[i].
arr[i]=arr[j].
arr[j]=store.
5. for (int i=0;i<=9;i++), then display arr[i]
6. Stop.
Flowchart:
Start
float arr[10],
store=0.
int i=0, j=0.
If T If T If T If T
Input
i<=9 ? i<=9 ? j<=9 ? arr[i]< A
arr[i]
arr[j]?
F F F
F
Stop B B
B
store=arr[i] T
A If
arr[i]=arr[j] arr[i]
j<=9 ?
arr[j]=store
F
B
B
#include<iostream>
using namespace std;
int main()
{
float arr[10], store=0;
int i=0, j=0;
for (i=0;i<=9;i++)
{
cin>>arr[i];
for (i=0;i<=9;i++)
{
for (int j=0;j<=9;j++)
{
if (arr[i]<arr[j])
{
store=arr[i];
arr[i]=arr[j];
arr[j]=store;
}
}
}
cout<<"----------------------------------------"<<endl;
cout<<"The inputted numbers in accsending are: "<<endl;
for (int i=0; i<=9; i++)
{
cout<<" "<<arr[i];
cout<<endl;
}
cout<<"----------------------------------------"<<endl;
system("pause");
return 0;
}
#include <iostream>
int main()
{
char Run = true;
do
{
int menu;
cout<<"-----------------------------------"<<endl;
cout<<"---------- M E N U ----------"<<endl;
cout<<"(1) Odd, Even, Zero"<<endl;
cout<<"(2) Area and Perimeter of a Rectangle"<<endl;
cout<<"(3) Area and Perimeter of a Circle"<<endl;
cout<<"(4) Positive, Negative, Zero of an Integer"<<endl;
cout<<"(5) Largest and Smallest"<<endl;
cout<<"(0) Exit the Program"<<endl;
cout<<"-------------------------------"<<endl;
cout<<endl;
cout<<"-------------------------------"<<endl;
cout<<"Enter your choice: ";
cin>>menu;
cout<<endl;
cout<<"-----------------------------------"<<endl;
{
if(menu==1)
{
int i=0, even=0, odd=0, zero=0, num;
for(i=0;i<=9;i++)
{
cout<<" Enter an integer: ";
cin>>num;
if (num==0)
{
zero = zero+1;
}
else if(num%2==0)
{
even = even+1;
}
else
{
odd = odd+1;
}
}
cout<<"-----------------------------------"<<endl;
cout<<"Total Even is: "<<even<<endl;
cout<<"Total Odd is: "<<odd<<endl;
cout<<"Total Zero is: "<<zero<<endl;
cout<<"-----------------------------------"<<endl;
}
if(menu==2)
{
float area, peri, l, w;
area = l*w;
peri = 2*(l+w);
for(i=0;i<=9;i++)
{
cout<<" Enter an integer: ";
cin>>num;
if (num>0)
{
positive = positive+1;
}
else if(num<0)
{
negative = negative+1;
}
else
{
zero = zero+1;
}
}
cout<<"-----------------------------------"<<endl;
cout<<"Total Positive is: "<<positive<<endl;
cout<<"Total Negative is: "<<negative<<endl;
cout<<"Total Zero is: "<<zero<<endl;
cout<<"-----------------------------------"<<endl;
}
if(menu==5)
{
int input, input1;
int tmp;
int counter = 0;
int max=0;
int min=0;
cout << "Enter a number: " << endl;
cin >> input1;
min=input1;
while (Run);
system("pause");
return 0;
}
ITC 104L