Hello, I am trying to test this program with gcc -Wall -Im but it is showing me
ID: 3889417 • Letter: H
Question
Hello, I am trying to test this program with gcc -Wall -Im but it is showing me this error "/tmp/cctn74rT.o: In function `main': voltage.c:(.text+0x42): undefined reference to `exp' collect2: ld returned 1 exit status"
this is the program
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
// defining the constants
#define V 10
#define R 3000
#define C 50 * pow(10,-6)
#define tau 0.15
int main()
{
//declaring the data types
float t, vt;
// displaying the header of the table
printf("Time (sec) voltage ");
// loop to calculate the voltage vt per the provided equation , 1/15 = 0.0666
for (t=0;t<=1;t=t+0.0666)
{
vt=V*(1 - exp(-t/tau));
// displaying data
printf("%0.02f %0.02f ",t,vt);
}
return 0;
}
// end
Explanation / Answer
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
// defining the constants
#define V 10
#define R 3000
#define C 50 * pow(10,-6)
#define tau 0.15
int main()
{
//declaring the data types
float t, vt;
// displaying the header of the table
printf("Time (sec) voltage ");
// loop to calculate the voltage vt per the provided equation , 1/15 = 0.0666
for (t=0;t<=1;t=t+0.0666)
{
vt=V*(1 - exp(-t/tau));
// displaying data
printf("%0.02f %0.02f ",t,vt);
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.