Mencari akar imajiner menggunakan C++ :
#include <iostream>
#include <string>
using namespace std;
int main(){
int x1;
int a;
int b;
int c;
double disk;
int x2;
cout<<"Input kan= ";
cin >> a;
cout<<"input kan= ";
cin >> b;
cout<<"input kan= ";
cin >> c;
disk =b*b-4*a*c;
if (disk>0)
{
x1 =-b/2*a;
x2 =x1;
}
else
{
if (disk==0)
{
x1 =(-b+sqrt(disk))/2*a;
x2 =(-b-sqrt(disk))/2*a;
}
else
{
cout << "Akar Imajinatier:" << endl; }
}
return 0;
}
Ouput :