C Program to A library charges a fine for every book returned late - IProgramX

Q. C Program - A library charges a fine for every book returned late. Accept the number of days the member is late, compute and print the fine as follows  (less than five days Rs ___ fine, for 6 to 10 days Rs. ____ fine and above 10 days Rs. ___ fine )


Program

#include<stdio.h>
int main()
{
int days, fine;
printf("Number of days late: ");
scanf("%d",&days);
if(days>0)
{
if(days<=5)
fine=5;
else if(days>5&&days<=10)
fine=10;
else if(days>10)
fine=20+days;
printf("you have to pay fine of Rs %d",fine);
}
else
printf("enter days not valid");
}

Output:

Number of days late: 6
you have to pay fine of Rs 10

Post a Comment

0 Comments