I've also tried adding fflush(stdout); after the printf statement and that didn't do anything, and neither did using fflush(stdin) before the scanf
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
float cost(int qty)
{
if (qty <= 20)
return qty * 23.45;
if (qty >= 21 && qty <= 100)
return qty * 21.11;
if (qty > 100)
return qty * 18.75;
return '0';
}
// void main() VS Only
int main()
{
int q;
printf("Enter quantity of books wanted: ");
scanf("&d", &q);
printf("\n\nThe total cost for purchasing books is: $%0.2f\n\n", cost(q));
}
#include <conio.h>
add this – kedar sedaireturn '0';
probably does not do what you think it does. ITYMreturn 0;
. – Jensscanf("&d", &q);
should get a warning such as "warning: too many arguments for format [-Wformat-extra-args]"/ – chux - Reinstate Monica