Sunday, August 31, 2014

A library charges a fine for every book returned late. For first 5 days the fine is 50 paise, for 6-10 days fine is one rupee and above 10 days fine is 5 rupees. If you return the book after 30 days your membership will be cancelled. Write a program to accept the number of days the member is late to return the book and display the fine or the appropriate message.


Code

#include<stdio.h>
#include<conio.h>
int main()
{
int days;
float fine;

printf("Number of days late: ");
scanf("%d",&days);

if(days<=30)
{
if(days<=5)
fine=0.5;
else if(days>5&&days<=10)
fine=1;
else if(days>10&&days<=30)
fine=5;
printf("you have to pay fine of Rs %f",fine);
}
else
printf("Your membership has been canceled");

printf ("\n\nPress any key to close.");

getch ();
return 0;
}

Output

library fine c language

4 comments :

Note: Only a member of this blog may post a comment.

Copyright 2017. All Rights Reserved. Privacy Policy / Terms And Conditions / Sitemap / Contact