Brijmohan lal Sahu - Facebook
Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Sunday, November 30, 2014

Program to enter hours and print numbers of days and remaining hours and convert remaining hours into minutes in C.




Code Box
----------------------------------------

/*Program to enter hours and print numbers of days and remaining hours and convert remaining hours into minutes */

#include<stdio.h>
#include<conio.h>
void main()
{

float hours,rhours,min;
/*hours for hours enter by User and rhours for remaining hours */

int days,h;
/*For numbers of Day */

clrscr();

printf("\n\tHours to Day Converter");
printf("\n\tEnter Hours :");
scanf("%f",&hours);

h=hours;

printf("\n\tHours:%d",h);
min=hours-h;
printf("\n\tRemaining Hours:%.2f",min);

min=(min*60);
printf("\n\tMinutes:%.2f",min);


rhours=h%24;

/*Modulus operator provide us the remainder after Division which is remaining hours */

days=(int)hours/24;
/*Division operator to calculate Days as we know 24 hours means 1 Day */

printf("\n\tNumber of Days : %d",days);
printf("\n\tRemaining Hours: %f",rhours);

getch();
}

No comments: