I'm trying to do this problem but am stuck once again.
The problem basically states
"Write a program that reads in the radius of a circle and prints the circle's diameter, circumference and area. use the constant value 3.14159 for pi. Perform each of these calculations inside the printf statements and use the conversion specifier %f." Computing in C 4th Edition.
I am still on chapter 2 and we have not learn about conversion specifiers yet. I think it starts on the next chapter. But below is what I came up with. The only problem is, I did not include the %f in there because I do not know how to use it. I am not sure why the book is wanting us to use something that is taught later on in the chapters. But anyway, another problem I have is, my calculations seems to be off when I checked it with a calculator. Does anyone know whats wrong with the code?
Code:
#include <stdio.h>
int main()
{
int r, pi;
pi = 3.14159;
printf( "Enter the radius of the circle: " );
scanf( "%d", &r );
printf( "The diameter is %d\n", 2 * r);
printf( "The circumference is %d\n", pi * 2 * r);
printf( "The area is %d\n", pi * r * r );
system ( "pause" );
return 0;
}