Hi today i noticed that this program [below] wont print the correct value and it always print 0.00000
#include <stdio.h>
#include <stdlib.h>
int main()
{
float S;
int n;
scanf("%d" , &n);
S=1/n;
printf ("%f", S);
return 0;
but when i asked my teacher he said you should make it like this
#include <stdio.h>
#include <stdlib.h>
int main()
{
float S;
int n;
scanf("%d" , &n);
S=(float)1/n;
printf ("%f", S);
return 0;
but when i asked why you did that ? what's that technique? he didnt gave me a clear answer so please make me understand what happens