timezone issue

I have an issue about making a timezone between departure time, destination time with the specific place timezone

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio.h>

int main()
{
	int s ;
	int t ;
	int f ;
	int x ;
	scanf("%d %d %d", &s, &t, &f);
	if(0<=s<=23 && 1<=t<=12 && -5<=f<=5 )
	{
		if(s+t>24){
			x= s+t+f-24;
			printf("%d\n", x);
		}
		else if(s+t+f == 24)
		{
			x=0;
			printf("%d\n", x);
		}
		else if(s==0)
		{
			x = t+f+6;
			
			
			printf("%d\n", x);
			
		}
		else if(s+t<23)
		{
			x = s+t+f;
			printf("%d\n", x);
		}
	}
}


the last else if statement will overprint the output.
how do I fix this issue any help is appreciated.
> if(0<=s<=23 && 1<=t<=12 && -5<=f<=5 )
This isn't how you check a number is between two values.

You need
if(0<=s && s <=23 && 1<=t && t <=12 && -5<=f && f <=5 )
if(0<=s && s <=23 && 1<=t && t <=12 && -5<=f && f <=5 )

I don't see much different about it. it works the same way with the previous statement.
Topic archived. No new replies allowed.