C++ program for complex numbers using class
#include<iostream> #include<conio.h> using namespace std; class complex { private: int real; int imag; public: void input() { cout<<"Enter real and imaginary part:-"; cin>>real>>imag; } void show() { cout<<"The complex no. "; cout<<real<<"+"<<imag<<"i"; } }; int main() { complex c1; c1.input(); c1.show(); getch(); return 0; }
Output:-
0 Comments