Why is this not submitting as correct? (to add upto n )

#include<stdio.h>
main()
{ int a;
scanf("%d",&a);
printf("%f", a*(a+1)*0.5);
return 0;
}

and neither is this-
#include<stdio.h>
main()
{ int a,s=0;
scanf("%d",&a);
while(a>0)
{ s=s+a;
a–;
}
printf("%d", s);
return 0;
}

printf("%d", (a*(a+1))*0.5);

while(a>0)
{
s=s+a;
a–;
}

Thankyou, but this gives integer part only and multiplying by 0.5 is making it float.

Same loop sir, not working