Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1:51 PM elearn.uta.edu \'11 AT&T; Write C programs for the following: 1. Write a

ID: 3590779 • Letter: 1

Question

1:51 PM elearn.uta.edu '11 AT&T; Write C programs for the following: 1. Write a function to ask to user a number of elements, create random decimal numbers ranging between -3 to 4 and write them into file called "data.Ext", seperated by commas. Hint: Use a for loop. 2. Using structures and upeded discussed in the #10 lecture write a program to do complex division between two complex numbers, i.e., /22 As a demonstration, compute 21/22 where 21-2.12 1.21 i and 22-2.8+7.8i The following program computes the product of two complex numbers includ

Explanation / Answer

#include<stdio.h>
#include<stdlib.h>
#include<time.h>

void f1(){

   FILE *fp;
   int a,i;

   fp = fopen("data.txt","w");
   srand(time(NULL));

   for(i=0;i<50; i++){
      a= rand()%4 -3;
      fprintf(fp,"%d ",a);
   }
   fclose(fp);
  
}

int main(){

     f1();
     return 0;
}

#include<stdio.h>
typedef struct{
      float Real;
      float Im;
}Complex;
Complex divide(Complex,Complex);
int main(){
    Complex z1,z2,z;

    z1.Real = 2.12; z1.Im = 1.21;
    z2.Real = -2.8; z2.Im = 7.8;
    z = divide(z1,z2);
    printf("z1 divided by z2 is : %f+%fi ",z.Real,z.Im);
    return 0;
}
Complex divide(Complex x,Complex y){
    Complex z;
    z.Real = (x.Real*y.Real + x.Im*y.Im)/(y.Real*y.Real+y.Im*y.Im);
    z.Im = (x.Im*y.Real - x.Real*y.Im)/(y.Real*y.Real + y.Im*y.Im);
    return z;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote