C/C program doesn't run
Expert: Narendra - 2/14/2007
QuestionI have written this code to find the value of the "Taylors" function. There are no errors but when I run it, nothing appears. This also goes for any code examples that I got online, all doesn't run. Please help me, my assignment is due tomorrow! Thanks.
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
int x=7;
int t=0;
float h=0.01;
float x_prime,x_2prime,x_3prime,taylors;
main()
{
x_prime=(t^2)+(x^2)+2*t*x;
x_2prime=(2*t)+(2*x*x_prime)+(2*t*x_prime)+(2*x);
x_3prime=2+(2*x*x_2prime)+(2*x_prime*x_prime)+(2*t*x_2prime)+(2*x_2prime)+(2*x_prime);
taylors=x+(h*x_prime)+((h*h/2)*x_2prime)+((h*h*h/6)*x_prime);
printf("x(0+0.01) is %f",taylors);
return;
}
AnswerI don't see anything wrong with the code.
It could be the OS/terminal that is having the problem.
So, what OS are you using and what terminal are you in?
If you are using MS Windows, then you can add getch() at the end (before return) to see the output.
If you are on Solaris (Unix) or Linux, this should work without any modification.
If it doesn't, then you must have replaced libc.so with some other file which has the definition of printf() which doesn't do anything.
You can do 'ldd executable name' to see what libraries it is compiled with.
-Narendra