flowchart dan program kasus 3.3
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main()
{
string raptor_prompt_variable_zzyz;
float x2;
float D;
int b;
int c;
float x1;
int a;
raptor_prompt_variable_zzyz ="A = ";
cout << raptor_prompt_variable_zzyz << endl;
cin >> a;
if (a!=0)
{
raptor_prompt_variable_zzyz ="B = ";
cout << raptor_prompt_variable_zzyz << endl;
cin >> b;
raptor_prompt_variable_zzyz ="C = ";
cout << raptor_prompt_variable_zzyz << endl;
cin >> c;
D =b^2-4*a*c;
if (D==0)
{
x1 =-b/2*a;
x2 =x1;
cout << "x1 = "<<x1<<" dan x2 = "<<x2 << endl; }
else
{
if (D>0)
{
x1 =(-b+sqrt(D))/2*a;
x2 =(-b-sqrt(D))/2*a;
cout << "x1 = "<<x1<<" dan x2 = "<<x2 << endl; }
else
{
cout << "akar imajiner" << endl; }
}
}
else
{
cout << "bukan persamaan kuadrat" << endl; }
system("pause");
return 0;
}
#include <string>
#include <math.h>
using namespace std;
int main()
{
string raptor_prompt_variable_zzyz;
float x2;
float D;
int b;
int c;
float x1;
int a;
raptor_prompt_variable_zzyz ="A = ";
cout << raptor_prompt_variable_zzyz << endl;
cin >> a;
if (a!=0)
{
raptor_prompt_variable_zzyz ="B = ";
cout << raptor_prompt_variable_zzyz << endl;
cin >> b;
raptor_prompt_variable_zzyz ="C = ";
cout << raptor_prompt_variable_zzyz << endl;
cin >> c;
D =b^2-4*a*c;
if (D==0)
{
x1 =-b/2*a;
x2 =x1;
cout << "x1 = "<<x1<<" dan x2 = "<<x2 << endl; }
else
{
if (D>0)
{
x1 =(-b+sqrt(D))/2*a;
x2 =(-b-sqrt(D))/2*a;
cout << "x1 = "<<x1<<" dan x2 = "<<x2 << endl; }
else
{
cout << "akar imajiner" << endl; }
}
}
else
{
cout << "bukan persamaan kuadrat" << endl; }
system("pause");
return 0;
}
Tidak ada komentar:
Posting Komentar