Find Out the Real and imaginary part of Complex Number



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Complex
    {
        double real, img;

        public Complex(double real, double img)
        {
            this.real = real;
            this.img = img;
        }
        public Complex()
        {
            real = 5;
            img = 7;

        }

        public void display()
        {
            Console.WriteLine("Complex Number is : {0}+{1}i", real, img);
        }

        public void mag()
        {
            double x;
            x = Math.Sqrt(real * real + img * img);
            Console.WriteLine("Magnitude of First complex Number is :{0}", x);
        }


        public static Complex operator +(Complex c1, Complex c2)///addition
        {
            return new Complex(c1.real + c2.real, c1.img + c2.img);
        }



        public override string ToString()
        {
            return string.Format("{0} + {1}i", real, img);
        }

    }
    class program
    {
        static void Main(string[] args)
        {

            double e, r;
            Complex c3 = new Complex();
            c3.display();
            c3.mag();

            Console.WriteLine("Enter Second Complex Number its real and imagenary parts");
            r = Convert.ToDouble(Console.ReadLine());
            e = Convert.ToDouble(Console.ReadLine());

            Complex c1 = new Complex();
            Complex c2 = new Complex(r, e);

            Complex sum = c1 + c2;
            Console.WriteLine("The sum of  two complex number is : {0}", sum);

            Console.ReadLine(); // Pause
        }
    }
}

Output
Continue Reading

Program To Check Character is Capital,Small,Special in C++

#include<iostream>
#include<conio.h>

using namespace std;

void main()
{
char ch;

cout<<"Enter the Character: ";
cin>>ch;

if(ch>=65&&ch<=90)
{
cout<<"\nCharacter is Capital";
}
else if(ch>=97&&ch<=122)
{
cout<<"\nCharacter is Small";
}
else if(ch>=48&&ch<=57)
{
cout<<"\nDigital";
}
else
{
cout<<"\nCharacter is Special";
}

getch();
}
Continue Reading

Program To Check Character is Capital,Small,Special in C++

#include<iostream>
#include<conio.h>

using namespace std;

void main()
{
char ch;

cout<<"Enter the Character: ";
cin>>ch;

if(ch>=65&&ch<=90)
{
cout<<"\nCharacter is Capital";
}
else if(ch>=97&&ch<=122)
{
cout<<"\nCharacter is Small";
}
else if(ch>=48&&ch<=57)
{
cout<<"\nDigital";
}
else
{
cout<<"\nCharacter is Special";
}

getch();
}
Continue Reading

Static Function And Factorial



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace staticFactorial
{
    public static class fact
    {
        

        public static long method(long factorial)
        {
          
           
                if (factorial > 1)
                {
                    return factorial * method(factorial - 1);
                }

                else
                {
                    return 1;
                }
               


        }
    }
    class Program
    {

        static void Main(string[] args)
        {

           
            Console.WriteLine("Enter Any Number : ");
            long factorial = Convert.ToInt32(Console.ReadLine());
            long x = fact.method(factorial);
            Console.WriteLine("factorial is : {0} ", x);
            Console.ReadLine();
          
          
        }
Continue Reading