My issue
include <bits/stdc++.h>
using namespace std;
int main() {
int X;
// Ask the user for the number of slices
cout << "Enter the number of slices (even number): ";
cin >> X;
// Ensure X is even
if (X % 2 != 0) {
cout << "Number of slices must be even." << endl;
return 1;
}
// Since all slices are equal, there will be no smaller pieces
int smallerPieces = 0;
// Output the result
cout << "Number of smaller pieces: " << smallerPieces << endl;
return 0;
}
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
int X;
// Ask the user for the number of slices
cout << "Enter the number of slices (even number): ";
cin >> X;
// Ensure X is even
if (X % 2 != 0) {
cout << "Number of slices must be even." << endl;
return 1;
}
// Since all slices are equal, there will be no smaller pieces
int smallerPieces = 0;
// Output the result
cout << "Number of smaller pieces: " << smallerPieces << endl;
return 0;
}
Problem Link: Chef loves Pizza Chef loves halfs Practice Coding Problem