Answer the question
In order to leave comments, you need to log in
What does #QNAN0 mean in C code?
I made a simple program in C. As written in the textbook, I used the conversion specification %f (decimal floating point number) when displaying results where necessary. At the output, I received #QNAN0 where I indicated this specification. What does this mean? And where is my mistake in the code?
#include <stdio.h>
/*Функция расчёта параметров окружности*/
main()
{
int r, d, l, s, pi; /*Объявляем пременные*/
pi = 3.14159;
printf("Enter radius of your circle:\n");
scanf("%d", &r);
printf("%d is the diameter of your circle\n", d = 2 * r);
printf("%f is the perimeter of your circle\n", l = 2 * pi * r);
printf("%f is the square of your circle\n", s = pi * (r * r));
return 0;
}
Enter radius of your circle:
10
20 is the diameter of your circle
-1.#QNAN0 is the perimeter of your circle
-1.#QNAN0 is the square of your circle
Process returned 0 (0x0) execution time : 2.289 s
Press any key to continue.
Answer the question
In order to leave comments, you need to log in
Because printf expects %f ---> double
and you slip it a signed integer
int
And the number pi is equal to three.
double d, l, s, pi; /*Объявляем пременные*/
int r = 0;
pi = 3.14159;
printf("Enter radius of your circle:\n");
scanf("%d", &r);
printf("%.2f is the diameter of your circle\n", d = 2 * r); // %.[кол-во знаков]f
printf("%.2f fis the perimeter of your circle\n", l = 2 * pi * r);
printf("%.2f is the square of your circle\n", s = pi * (r * r));
Enter radius of your circle: 10
20.00 is the diameter of your circle
62.83 fis the perimeter of your circle
314.16 is the square of your circle
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question