Selasa, 30 Juni 2015

C++ PROGRAM PERSAMAAN KUADRAT 

C++ PROGRAM PERSAMAAN KUADRAT 

#include <iostream>
#include <math.h>
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;
int main(int argc, char *argv[]) {

int a, b, c;
float x1, x2, D;

cout<<"=========================================\n";
cout<<"| <<<<<<PROGRAM PERSAMAAN KUADRAT>>>>>> |\n";
cout<<"=========================================\n\n";
cout<<"Masukkan nilai a = "; cin>>a;
cout<<"\nMasukkan nilai b = "; cin>>b;
cout<<"\nMasukkan nilai c = "; cin>>c;

D=((b*b)-4*(a*c));

if (a==0){
cout<<"Bukan Persamaan Kuadrat";
}
else if (D>0){
x1=((-b)+(sqrt(D)))/(2*a);
x2=((-b)-sqrt(D))/(2*a);
cout<<"persamaan kuadrat ("<<a<<"^2)x + "<<b<<"x +"<<c<<" mempunyai akar-akar yang berbeda yaitu : \n";
cout<<"X1 = "<<x1<<endl;
cout<<"X2 = "<<x2<<endl;
}
else if (D==0){
x1=(-b)/(2*a);
x2=x1;
cout<<"persamaan kuadrat "<<a<<"^2 + "<<b<<"x +"<<c<<" mempunyai akar-akar kembar yaitu : \n";
cout<<"X1 = "<<x1<<endl;
cout<<"X2 = "<<x2<<endl;
} else { cout<<"Akar Imaginer";
}
return 0;
}

HASIL COMPILE :


Related Posts:

  • C++ Program Jam Digital (tanpa CLASS )Program Jam Digital Bahasa C++ ( tanpa CLASS ) #include <iostream> #include <ctime> #include <cstdlib> #include <windows.h> /* run this program using the console pauser or add your own getch, system("… Read More
  • Pascal - Program Tukar Tiga Bilangan Program Tukar Tiga Bilangan menggunakan Bahasa Pascal program Tukar_Tiga_Bilangan; {Dibaca tiga buah bilangan yang bertipe data integer, ditukar ketiga bilangan kemudian tampilkan hasilnya di layar}       &nb… Read More
  • C++ PROGRAM MENCARI BILANGAN TERBESAR DAN TERKECIL ( CLASS ) C++ PROGRAM MENCARI BILANGAN TERBESAR DAN TERKECIL  ( CLASS ) #include <iostream> #include <cstdlib> using namespace std; /* run this program using the console pauser or add your own getch, system("pause") o… Read More
  • C++ Program JAM DIGITAL ( CLASS )Program JAM DIGITAL bahasa C++ menggunakan CLASS #include <iostream> #include <ctime> #include <cstdlib> #include <windows.h> /* run this program using the console pauser or add your own getch, system… Read More
  • C++ PROGRAM PERSAMAAN KUADRAT C++ PROGRAM PERSAMAAN KUADRAT  #include <iostream> #include <math.h> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; int main(int ar… Read More

0 komentar:

Posting Komentar