0
Can anyone tell me why this program to find x to the power of n and sin(x) is wrong? Its a basic C program. I'm still learning.
#include<stdio.h> #include<math.h> #include<conio.h> main() { double r,x,y,z,n; clrscr(); printf("Key in values for x, n and sin(x): \n"); scanf("%f%f%f", x, n, z); r = z* 3.14159/180.0 ; y = sin(r); printf("sin(%f) = %f \n" , z, y); y = sqrt(x); printf("sqrt(%f) = %f \n" , x, y); y = pow(x,n); printf("%f to the power %f = %f\n", x,n, y); getchar(); }
1 Réponse
+ 2
You declared double types use %lf.
Correct way :
scanf("%lf %lf %lf", &x, &n, &z);