0
What should I change to get discount
#include<stdio.h> void greeting (); void discountcalculator(int x,int y,int s); int main() { int x,y,s; greeting (); printf("Key in your age:"); scanf("%d",&x); printf("Key in the amount you spent:"); scanf("%d",&y); if(x>=18) printf("Your age is %d and ",x); else ("The age entered is invalid"); if(y>=1000) printf("your discount is %d", s); else printf("You are not eligible for a discount."); } void greeting () { printf("Welcome!\n"); } void discountcalculator(int x,int y,int s) { printf("%d=%d*0.05",y*0.05); scanf("%d",&s); }
1 Respuesta
+ 1
if(y>=1000)
printf("your discount is %lf", discountcalculator(y) ); // call function with y value passing.. No need of x, and s;
//and this is function which returns double type value discount to the call..
double discountcalculator(int y)
{
double s = y*0.05; // calculate
return s ; //change return type to double.
}