While purchasing certain items a discount of 10% is offered if the quantity purchased is more than 2000. Write a program to calculate the total expanses, if quantity and price per item are entered through keyboard.

#include<stdio.h>

float discount(float p);

int main()
{
    float p,total,q;
    printf("\nEnter quantity=");
    scanf("%d",&q);
    printf("\nEnter price per item=";
    scanf("%d",&p);
    total=p*q-discount(p*q);
    printf("\nTotal expanses=",total);
    return 0;
}

float discount(float p)
{   
    if(p>=2000)
        return p*0.10;
    else
        return 0;
}

No comments:

Post a Comment