Directions: Convert the following problem below to c++ equivalent code
Problem 5:
Problem 8:
For this problem I want you to draw out a flow chart to illustrate the logic. You may use word, DIA, or any other software you choose but be specific on the symbols used to illustrate this problem. If you use hand drawn, make sure the paper is unlined and that your picture of it is clear and legible. Please submit this problem as an image file
PROBLEM 5
C++ PROGRAM
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int n,x;;
cout<<endl<<"Enter a number";
cin>>n;
x=n;//assign the user entry number to x
x=x*4; //multiply x by 4
x=x+1;//add 1 to x
x=x*n;//multiply x by user entry number
x=x-n;//subtract the user entry number from x
x=sqrt(x); //find the square root of x
x=x/2;//devide x by 2
if(x==n) //check whether x and n equal or not. The
result will always will be trur
cout<<endl<<"Equal";
else
cout<<endl<<"Unequal";
}
OUTPUT
PROBLEM 8
FLOWCHART USING FLOWGARITHM
OUTPUT
FLOWCHART INLARGE SIZE
C++ PROGRAM
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int x,a,b;;
do
{
cout<<endl<<"Enter a number";
cin>>x;//input the number
}while(x<10 || x>99);//check for 2 digit or
not
do
{
x=x/2;//devide by 2
x=x+17;//add 17
a=x %10;//find the unit place digit
b=x/10;//find the 10's place digit
if(b>a) //compare b with a and do the necessary
action
x=x+b;
else
x=x+a;
if(x>21) //check whether the number greater to 21
or not
x=x-(a*b); //subtract (a*b)if greater to
21
}while(x<21);//continue the process till the number
less than 21
cout<<endl<<"nUMBER IS
"<<x;//display the number
}
OUTPUT
Get Answers For Free
Most questions answered within 1 hours.