include stdioh struct complex


  #include stdio.h
  struct  complex
  {
  float real;
  float imag;
  };
  struct complex complexadd(struct complex,struct  complex);
  void main()
    {
   
     Date: 26th August 1992 
    Version 1.0 
    Function : To add two complex numbers to gether uses function
         complecxaddd

     /* Define two complex numbers */
  char prompt;
  struct  complex z1,z2,z3;
  printf("Please enter in number 1  a+jb ");
  printf(" \n\rEnter in the real part of a =  ");
  scanf("%f",&(z1.real));
  printf(" \n\rEnter in the complex part of b =  ");
  scanf("%f",&(z1.imag));
  printf("Please enter in number 2  a+jb ");
  printf(" \n\rEnter in the real part of a =  ");
  scanf("%f",&(z2.real));
  printf(" \n\rEnter in the complex part of b = ");
  scanf("%f",&(z2.imag));
  z3 = complexadd(z1,z2);
  printf("\n\rThe solution is a+jb where a = %f and b = %f   ",z3.real,z3.imag);
  printf("Press and key to exit \n\r");
  scanf("\n%c",&prompt);
  }
 
struct complex complexadd(struct complex a1, struct complex b1)
  {

     Date: 26th August 1992 
    Version 1.0 
    Function : Add two complex structures together and returns the answer as a complex structure       
     Modifications:   none*/
 
  struct complex result;
  /* Add the real parts together */
  result.real = a1.real + b1.real;
  /* add the imaginary parts together */
  result.imag = a1.imag + b1.imag;
  return(result);
  }
 
Good functions should return back also a status indicating whether it has passed or failed, look at scanf and string functions etc.

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: include stdioh struct complex
Reference No:- TGS0265297

Expected delivery within 24 Hours