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



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

Answer / 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

More C Interview Questions

What is a global variable in c?

0 Answers  


wat is the difference between a definition and declaration? float y;---it looks like a declaration..but it s a definition.how?someone explain

3 Answers   TCS,


which is conditional construct a) if statement b) switch statement c) while/for d) goto

0 Answers  


What are comments and how do you insert it in a C program?

0 Answers  


there is two conditions , 1. while using for loop for printing 1 to 50 no's simulteneous 2. while using printf functios for printing 1 to 50 no's simulteneous with or without using variables who will take more time for compiling and execution? explain in details with reason?

1 Answers  






How to reverse a string using a recursive function, with swapping?

5 Answers  


What is pass by reference in c?

0 Answers  


what is a stack

3 Answers  


which of the following statements is incorrect a.typedef struct new{ int n1; char n2; } DATA; b.typedef struct { int n3; char *n4; }ICE; c.typedef union { int n5; float n6; } UDT; d.#typedef union { int n7; float n8; } TUDAT;

5 Answers   Assurgent, TCS,


How can I access an I o board directly?

0 Answers  


Write a program to generate the first n terms in the series --- 2,3,5,7,11,...,17

0 Answers  


what will happen if you free a pointer twice after allocating memory dynamically ?

3 Answers   Novell,


Categories