adsense

Hii, welcome to my site. My name is Om prakash kartik. This blog helps you to learn programming languages concepts.

c++ program for complex numbers using class

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:-





Post a Comment

0 Comments