Help me in solving BOOKPACK problem

My issue

Hello! The commented code works absolutely fine and covers all the test cases, but the code which I have written using ceil(), is failing the last test case. I can’t figure out the difference between the commented code and my code.

Kindly let me know why its not working. It would be better if you have example of such test case.

My code

#include <bits/stdc++.h>
using namespace std;

int main() {

	int t;
	cin>>t;

	while(t--){

	    int x,y,z;
	    cin>>x>>y>>z;

	   // if(y > z){

	   //     if(y % z == 0){
	   //         cout<<(y/z) * x<<endl;
	   //     }
	   //     else{
	   //         cout<<(y/z + 1) * x<<endl;
	   //     }
	   // }
	   // else{
    //         cout<<x<<endl;
	   // }

	   cout<< x * ceil((float)y / z) << endl; 
	}

	return 0;
}

Problem Link: BOOKPACK Problem - CodeChef

@smeet8267
Just store the ceiling value first in some variable then multiply it with x then return the answer .
like this

#include <bits/stdc++.h>
using namespace std;

int main() {

	int t;
	cin>>t;

	while(t--){

	    int x,y,z;
	    cin>>x>>y>>z;
	    y=ceil(y*1.0/z*1.0);
	    y=y*x;

	   cout<< y << endl; 
	}

	return 0;
}

@dpcoder_007

int main() {

	int t;
	cin>>t;

	while(t--){

	    int x,y,z;
	    cin>>x>>y>>z;

        int temp = ceil((float)y / z);

        cout<< x *  temp<< endl; 
	}

	return 0;
}

Great! Now this code is giving correct answer, but I’m more confused! I haven’t seen such thing before, like what is the difference in first storing and then printing it? Its difficult to handle. Why can’t we just do it in one line?