Algorithm #1: Step1: Enter A Step2: If A is greater than 0 and A is less than 99
ID: 3633068 • Letter: A
Question
Algorithm #1:Step1: Enter A
Step2: If A is greater than 0 and A is less than 99
Step 3: Then go to step 5
Step 4: Else go to step 10
Step 5: Divide A with 25
Step 6: Store the co-efficient in Q
Step 7: Store Remainder in A
Step 8: Divide A with 10
Step 9: Store the co-efficient in D
Step 10: Store Remainder in A
Step 11: Divide A with 5
Step 12: Store the co-efficient in N
Step 13: Store Remainder in A
Step 14: Store A in P
Step 15: Display Q, D, N, and P
Step 16: Invalid input
Step 17: STOP
Algorithm #2:
Step 1: Enter A
Step 2: Enter B
Step 3: Enter C
Step 4: Enter D
Step 5: Enter E
Step 6: If A < Lowest
Step 7: Lowest=A
Step 8: If B < Lowest
Step 9: Lowest =B
Step 10: If C < Lowest
Step 11: Lowest = C
Step 12: If D < Lowest
Step 13: Lowest = D
Step 14: If E < Lowest
Step 15: Lowest = E
Step 16: Display Lowest
Step 17: If A > Highest
Step 18: Highest = A
Step 19: If B > Highest
Step 20: Highest = B
Step 21: If C > Highest
Step 22: Highest = C
Step 23: If D > Highest
Step 24: Highest = D
Step 25: If E > E
Step 26: Highest = E
Step 27: Display Highest
Step 28: Find sum (A+B+C+D+E)
Step 29: Divide sum by 5
Step 30: Display Average
Step 31: STOP
Explanation / Answer
Algorithm 1:
#include <iostream>
using namespace std;
int main()
{
int A, Q, D, N, P;
cout << "Enter A: ";
cin >> A;
if(A > 0 && A < 99)
{
Q = A / 25;
A = A % 25;
D = A / 10;
A = A % 10;
N = A / 5;
A = A % 5;
P=A;
cout<<"Q = "<<Q<<", D = "<<D<<", N = "<<N<<", P = "<<P<<endl;
}
else
{
cout<<"Invalid Input";
}
return 0;
}
Algorithm 2:
#include <iostream>
using namespace std;
int main()
{
int A,B,C,D,E, Lowest=0, Highest=0;
cout<<"Enter A"<<endl;
cin>>A;
cout<<"Enter B"<<endl;
cin>>B;
cout<<"Enter C"<<endl;
cin>>C;
cout<<"Enter D"<<endl;
cin>>D;
cout<<"Enter E"<<endl;
cin>>E;
Lowest = A;
if (A < Lowest)
Lowest = A;
if (B < Lowest)
Lowest = B;
if (C < Lowest)
Lowest = C;
if (D < Lowest)
Lowest = D;
if (E < Lowest)
Lowest = E;
cout<<"Lowest is : "<<Lowest<<endl;
if (A > Highest)
Highest = A;
if (B > Highest)
Highest = B;
if (C > Highest)
Highest = C;
if (D > Highest)
Highest = D;
if (E > Highest)
Highest = E;
cout<<"Highest is : "<<Highest<<endl;
int sum = 0;
sum = A+B+C+D+E;
sum = sum/5;
cout<<"Average is : "<<sum<<endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.