Posted By:
21 Jun, 2013 9:09 am PDT

Structures in C

How can you use structures to add, subtract, multiply and divide complex numbers?
Attachment:None


 

We can use if and if else statements for structures and using if else statements we can add, subtract, multiply and divide complex numbers..

 

In this example we have given choices for each operation and the user has to select the corresponding choice. We use the if and else statements to decide the choice and execute the corresponding operation.
Please see the video for more details.

 

Was it useful?  



We cannot simply add both the complex numbers as they contain both real and imaginary numbers.

complex3.real = complex1.real + complex2.real;
complex3.imag = complex1.imag + complex2.imag;

Take care of the values when subtraction and division is done . Programs are learnt when experimented.:) 

Thats how addition is done for the complex numbers and the same can be applied for the remaining arithmetic operations. Please see the attached file on how the addition is done .


Was it useful?  




Please login to reply to this problem.