I am begining with C and have exercise with a program that will display the duration in hours and minutes of the journey (assumed to take place all in one day) so i write this:
#include<stdio.h>
void main(void)
{
int DptTime,ArrTime,hours,mins,Dmins,Amins;
float DHours,AHours;
printf("Type in Departure Time:"scanf("%i",&DptTime);
printf("Type in Arrival Time:"scanf("%i",&ArrTime);
hours=DptTime/100; mins=DptTime%100;
DHours=hours+mins/60.0;
Dmins=DHours*60+0.5;
hours=ArrTime/100; mins=ArrTime%100;
AHours=hours+mins/60.0;
Amins=AHours*60+0.5;
mins=Amins-Dmins;
hours=mins/60;
mins=mins%60;
printf("%i:%i\n",hours,mins);
}
--------------------------------------------------------------------------------
it's work but could i find another code to write this program
#include<stdio.h>
void main(void)
{
int DptTime,ArrTime,hours,mins,Dmins,Amins;
float DHours,AHours;
printf("Type in Departure Time:"scanf("%i",&DptTime);
printf("Type in Arrival Time:"scanf("%i",&ArrTime);
hours=DptTime/100; mins=DptTime%100;
DHours=hours+mins/60.0;
Dmins=DHours*60+0.5;
hours=ArrTime/100; mins=ArrTime%100;
AHours=hours+mins/60.0;
Amins=AHours*60+0.5;
mins=Amins-Dmins;
hours=mins/60;
mins=mins%60;
printf("%i:%i\n",hours,mins);
}
--------------------------------------------------------------------------------
it's work but could i find another code to write this program