include stdioh include mathhfloat


#include stdio.h
#include math.h

float discharge(float,float);
void main()
  {
  char prompt;   
  float time,out,cr;
  cr = 100e-6;
  for (time = 0;time<=5*cr;time+=10e-6)
  {
  /* call the function */
  out = discharge(time,cr);
  /*Note g formattor defaults to expontential */
printf("The capacitor voltage at time %10.5g seconds  is %5.3f \n\r ",time,out);
  }    
  printf("Press any key to exit \n\r");
  scanf("\n%c",&prompt);  
  }
 
float discharge(float t,float cr)
{
  float vs,vc;
  /* calculate the discharge */
  vs = 10.0;
  vc = vs*exp(-t/cr);
  return(vc);
}

Request for Solution File

Ask an Expert for Answer!!
C/C++ Programming: include stdioh include mathhfloat
Reference No:- TGS0414854

Expected delivery within 24 Hours