My code only worked for 3 test cases and failed for other 2. What's wrong in my code?

You are given N golden balls,you have to find the maximum height of triangle it can form with that balls.

A traingle with height X will have X balls in the bottom most level and 1 ball in the top most level

each upper level will have exactly one ball less than its bottom level.

//here’s my code
#include<stdio.h>
#include<math.h>
int main()
{
int t;
long long int n;
float h;
scanf(“%d”,&t);
while(t–)
{
scanf(“%lld”,&n);
h=(-1+sqrt(1+8*n)/2;
printf(“%d\n”,(int)h);
}
return 0;
}

here in this part of the code try this :
h=(-1+sqrt(1+8*n)/2; ===> h = (-1 + (sqrt(1 + 8 * n)) / 2;