visual studio 2010 - How to input decimal in c -


i trying input decimal in program, giving me different output. have used %5.2f, float , double, , still not working. want calculate diameter, area , circumference of circle, output different.

#include<stdio.h> #include<conio.h> #include<math.h> #include<ctype.h>  int main(int argc, char**argv) {     double radius;     double pi = 3.14;     double diameter;     double area;     double circumference;      printf("\t\tenter value radius: ");     scanf_s("%5.2f", &radius);     printf("radius %5.2f", radius);      diameter = radius*2;     area = pi*(radius*radius);     circumference = 2*(pi*radius);      printf("\n\t\tthe diameter of circle %d \n", diameter);     printf("\t\tarea: %d", area);     printf("\t\tcircumference: %d", circumference);     getch();     return 0; } 

please tell me mistakes, also, tried using m_pi have mathematical constant, not work.

the correct input format specifier double %lf (or %lg or %le).

scanf_s("%lf", &radius); 

when print again, can format want.

printf("radius %5.2f", radius); 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -