Write a program to add a given duration with time(24hrs format)

Answer Posted / heena r yeole

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

int dept1,dept2,dept3,dept4,dept5,dept6,dept7,dept8,hh,mm,entertime;

printf("Enter a time in 24-hour format:");
scanf("%d:%d",&hh,&mm);


dept1=8*60;
dept2=9*60+43;
dept3=11*60+19;
dept4=12*60+47;
dept5=14*60;
dept6=15*60+45;
dept7=19*60;
dept8=21*60+45;

entertime=hh*60+mm;

if(entertime<=dept1){
printf("Closet Departure time is 8:00 A.M,arriving at 10:16 A.M");
}else if(entertime<=dept2){
printf("Closet Departure time is 9:43 A.M,arriving at 11:52 A.M");
}else if(entertime<=dept3){
printf("Closet Departure time is 11:19 A.M,arriving at 1:31 P.M");
}else if(entertime<=dept4){
printf("Closet Departure time is 12:47 P.M,arriving at 3:00 P.M");
}else if(entertime<=dept5){
printf("Closet Departure time is 02:00 P.M,arriving at 4:08 P.M");
}else if(entertime<=dept6){
printf("Closet Departure time is 03:45 P.M,arriving at 5:55 P.M");
}else if(entertime<=dept7){
printf("Closet Departure time is 07:00 P.M,arriving at 9:20 P.M");
}else if(entertime<=dept8){
printf("Closet Departure time is 09:45 P.M,arriving at 11:58 P.M");
}

Is This Answer Correct ?    2 Yes 9 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the scope of static variables?

595


Write a program to check armstrong number in c?

630


PLS U SENS ME INTERVIEW O. MY EMAIL ADD, SOFIYA.SINGH@GMAIL.COM

1697


Is a house a mass structure?

635


Write a program to find factorial of a number using recursive function.

634






What is function prototype in c with example?

565


Is anything faster than c?

575


find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2

1521


What is cohesion and coupling in c?

582


what are non standard function in c

1423


Why is it usually a bad idea to use gets()? Suggest a workaround.

893


What is a structure and why it is used?

613


What is the scope of static variables in c language?

622


1. Write a function to display the sum of two numbers in the following ways: By using (i) pass by value (ii) pass by address a. function with argument and with return value b. function with argument and without return value c. without argument , with return value d. without argument , without return value Note: Use pass by address.

2328


What does void main () mean?

720