- Carilah akar-akar persamaan kuadrat.
C++ :
#include <cstdlib>
#include <iostream>
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
string raptor_prompt_variable_zzyz;
int A, B, C;
long disk;
float x1, x2;
cout<<”koefisien pangkat 2 :”;cin>>A;
cout<<”koefisien pangkat 1 :”;cin>>B;
cout<<”koefisien pangkat 0 :”;cin>>C;
if(A==0){
cout<<”bukan pers. kuadrat.\n”;
cout<<”harga akar =”<<-C/B;}else{
disk =B*B-4*A*C;
if(disk > 0){
x1=-B+sqrt(disk)/(2*A);
x2=-B-sqrt(disk)/(2*A);
cout<<”diskriminan =”<<disk<<endl;
cout<<”x1 =”<<x1<<endl;
cout<<”x2 =”<<x2<<endl;
}else if(disk == 0){
x1=-B/(2*A); x2=x1;
cout<<”x1 =”<<x1<<endl;
cout<<”x2 =”<<x2<<endl;
}else cout<<”akar imajiner”;
}
system(“PAUSE”);
return EXIT_SUCCESS;
}
{
string raptor_prompt_variable_zzyz;
int A, B, C;
long disk;
float x1, x2;
cout<<”koefisien pangkat 2 :”;cin>>A;
cout<<”koefisien pangkat 1 :”;cin>>B;
cout<<”koefisien pangkat 0 :”;cin>>C;
if(A==0){
cout<<”bukan pers. kuadrat.\n”;
cout<<”harga akar =”<<-C/B;}else{
disk =B*B-4*A*C;
if(disk > 0){
x1=-B+sqrt(disk)/(2*A);
x2=-B-sqrt(disk)/(2*A);
cout<<”diskriminan =”<<disk<<endl;
cout<<”x1 =”<<x1<<endl;
cout<<”x2 =”<<x2<<endl;
}else if(disk == 0){
x1=-B/(2*A); x2=x1;
cout<<”x1 =”<<x1<<endl;
cout<<”x2 =”<<x2<<endl;
}else cout<<”akar imajiner”;
}
system(“PAUSE”);
return EXIT_SUCCESS;
}
0 Comment to "Minggu ke-3 ALPRO (Kasus 3.3)"
Post a Comment