I am new to programming and learning C from schildt's teach yourself C. I am trying to make a function that returns square. but when I input numbers with decimals it outputs as whole number. why does it do that? my program :
#include <stdio.h>
int get_sqr(void);
void main()
{
float x;
x = get_sqr();
printf("square : %f",x);
return 0;
}
int get_sqr(void)
{
float y;
printf("enter a number : ");
scanf("%f",&y);
return y*y; /*returning the square result to assignment argument */
}