I am trying to make a Time Checker for my "Make a Grocery Store Project". Problem is that when I try to do an error-check for wrong userinput, it doesn't let me compare the two variables. I'm relatively new to coding so if you also have any problem with the way I layout my code and how I could improve, please do so.
// Online C compiler to run C program online
#include <stdio.h>
int tallytotal;
int countertimeslots;
double timeslots = 22.00;
int main() {
void TimeSlotsPrinter(double t);
printf("Please pick the total of items: ");
scanf("%d", &tallytotal);
countertimeslots = tallytotal;
TimeSlotsPrinter(countertimeslots);
}
void TimeSlotsPrinter(double t){
if(countertimeslots >= 260){
int v = 0;
for(v; countertimeslots / 260 > v; ++v);
printf("\nYou have chosen over %d items", countertimeslots);
printf("\nThis means that you would have to wait %d additional day after tomorrow to pick up your items\n", v);
countertimeslots -= 260 * v;
}
countertimeslots /= 20;
double x = 9;
x +=countertimeslots;
printf("The time available is as follows..");
for(x; timeslots>=x; ++x){
printf("\n%.2lf", x);
t--;
}
printf("\n**Beware that higher items means longer preparation time**");
PickTime:
printf("\nPlease enter your desired timeslot:");
scanf("%d", &countertimeslots);
if(countertimeslots << t && countertimeslots >> 22){
printf("\nUnavailable time. Please pick another");
goto PickTime;
}
else if(countertimeslots % 12 << 1){
printf("You have selected %dAM", countertimeslots);
}
else
{
countertimeslots -= 12.00;
printf("You have selected %dPM", countertimeslots);
}}
*Error
I expected this to work since when you divide integer 1 in C with any integer greater than that, it would always produce 0.enter image description here
<<and>>are bitwise-shift operators. They do not mean very greater and very less.You may compare the two operands with the
<(less than),>(greater than) operators.