You’re hitting undefined behavior for the below line
 result = result*num;
as you’ve not initialized result. The initial value for an uninitialized automatic local variable is indeterminate. Using that invokes UB.
Always initialize your local variables, like
 int count = 0 , result = 0 ; //0 is for illustration, use any value, but do use
Then coming to the case, where you want to change all ints to float, only changing the data type of the variable is not sufficient. You need to change the corresponding format specifiers, too.
5
solved Variable Buffer?