Program c++
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main()
{
string raptor_prompt_variable_zzyz;
int a,b,c;
float disk,x1,x2;
raptor_prompt_variable_zzyz ="masukan nilai a";
cout << raptor_prompt_variable_zzyz << endl;
cin >> a;
raptor_prompt_variable_zzyz ="masukan nilai b";
cout << raptor_prompt_variable_zzyz << endl;
cin >> b;
raptor_prompt_variable_zzyz ="msukan nilai c";
cout << raptor_prompt_variable_zzyz << endl;
cin >> c;
disk =(b*b)-(4*a*c);
if (disk>0)
{
x1 =-b+sqrt(disk)/2*a;
x2 =(-b)-sqrt(disk)/2*a;
cout << x1 << endl; cout << x2 << endl; }
else
{
if (disk==0)
{
x1 =-b/2*a;
x2 =x1;
cout << x1 << endl; cout << x2 << endl; }
else
{
cout << "akar imajiner" << endl; }
}
system("pause");
return EXIT_SUCCESS;
}
Flowchart:
Tidak ada komentar:
Posting Komentar