Please check this code and rewrite it thanks //in this we will convert flow char
ID: 3805291 • Letter: P
Question
Please check this code and rewrite it thanks
//in this we will convert flow chart into code
#include<iostream>
using namespace std;
int main()
{
double a, b, c;
double func_a, func_b, func_c;
cout << "Enter the values of a and c ." << endl;
cin >> a >> c;
cout << "Enter the salinity measurement of b ." << endl;
cin >> b;
cout << "Enter the value of func_a and func_c ." << endl;
cin >> func_a >> func_c;
if (a < b && b < c)
{
func_b = func_a + (b - a) / (c - a)*(func_c - func_a);
cout << "F(b) is =";
cout << func_b << endl;
}
else
{
cout << "Invalid data a,b,c !" << endl;
}
system("pause");
return 0;
}
Explanation / Answer
#include<iostream>
using namespace std;
int main()
{
double a, b, c;
double func_a, func_b, func_c;
cout << "Enter the values of a and c ." << endl;
cin >> a >> c;
cout << "Enter the salinity measurement of b ." << endl;
cin >> b;
cout << "Enter the value of func_a and func_c ." << endl;
cin >> func_a >> func_c;
if (a < b && b < c)
{
func_b = func_a + (b - a) / (c - a)*(func_c - func_a);
cout << "F(b) is =";
cout << func_b << endl;
}
else
{
cout << "Invalid data a,b,c !" << endl;
}
system("pause");
return 0;
}