Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Extend the code given in the photo above by encoding the additional four functions that allow the user to do the following operations. a.Multiplication of

image text in transcribed

Extend the code given in the photo above by encoding the additional four functions that allow the user to do the following operations.

a.Multiplication of a Complex object with a scalar

b.Division of a Complex object with a scalar

c.Two differentfunctions; one forreturning only the real andone for returningimaginarypart of the Complex object.

NOTE:write the code in the C programming language

#include #include struct Complex { float real; float imag; typedef struct Complex Complex; complex add(Complex n1, Complex n2); void Print(Complex n); float Abs (Complex n); int main() 8 9 1e 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 Complex ni, n2, temp; printf("For 1st complex number "); printf("Enter real and imaginary part respectively: "); scanf("%f %f",8n1.real, &n1.imag); Print(ni); printf(" For 2nd complex number "); printf("Enter real and imaginary part respectively: "); scanf("%f %f",&n2.real, &n2.imag); Print(n2); temp =add(ni, n2); printf("Sum = "); Print(temp); printf("absolute value of the sum = %f", Abs (temp)); return e; } complex add(Complex ni, complex n2) { Complex temp; temp.real = 1.real+ n2.real; temp. imag=nl. imag+ n2.imag; return(temp); } void Print (Complex n) { printf("%.1f + %.1fi ", n.real,n.imag); > float Abs(Complex n) return sqrt(pow (n.real, 2) + pow(n.imag, 2)); }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle9i Database Administrator Implementation And Administration

Authors: Carol McCullough-Dieter

1st Edition

0619159006, 978-0619159009

More Books

Students also viewed these Databases questions

Question

1. Does your voice project confidence? Authority?

Answered: 1 week ago