Algorithm


 problem Link : https://www.codechef.com/problems/KITCHENTIME 

Problem

The working hours of Chef’s kitchen are from  pm to  pm (1≤�<�≤12).

Find the number of hours Chef works.

Input Format

  • The first line of input will contain a single integer , denoting the number of test cases.
  • Each test case consists of two space-separated integers  and  — the starting and ending time of working hours respectively.

Output Format

For each test case, output on a new line, the number of hours Chef works.

Constraints

  • 1≤�≤100
  • 1≤�<�≤12

Sample 1:

Input
 
Output
 
4
1 2
3 7
9 11
2 10
1
4
2
8

Explanation:

Test case 1: Chef starts working at 1 pm and works till 2 pm. Thus, he works for 1 hour.

Test case 2: Chef starts working at 3 pm and works till 7 pm. Thus, he works for 4 hours.

Test case 3: Chef starts working at 9 pm and works till 11 pm. Thus, he works for 2 hours.

Test case 4: Chef starts working at 2 pm and works till 10 pm. Thus, he works for 8 hours.

Code Examples

#1 Code Example with C Programming

Code - C Programming

#include<stdio.h>

int main(void) {
	int t,start,end;
	scanf("%d",&t);
	while(t--)
	{
	    scanf("%d %d",&start,&end);
	    printf("%d\n",end-start);
	}
	return 0;
} 
Copy The Code & Try With Live Editor

Input

x
+
cmd
4
1 2
3 7
9 11
2 10

Output

x
+
cmd
1
4
2
8
Advertisements

Demonstration


CodeChef solution KITCHENTIME  - Kitchen Timings Codechef solution in C, C++

Previous
CodeChef solution DETSCORE - Determine the Score Codechef solution in C.C++
Next
CodeChef solution TAXES - Tax in Chefland CodeChef solution in C,C++