Algorithm
problem Link : https://www.codechef.com/problems/KITCHENTIME
Problem
The working hours of Chef’s kitchen are from pm to pm .
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
Sample 1:
4 1 2 3 7 9 11 2 10
1 4 2 8
Explanation:
Test case : Chef starts working at pm and works till pm. Thus, he works for hour.
Test case : Chef starts working at pm and works till pm. Thus, he works for hours.
Test case : Chef starts working at pm and works till pm. Thus, he works for hours.
Test case : Chef starts working at pm and works till pm. Thus, he works for 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
1 2
3 7
9 11
2 10
Output
4
2
8
Demonstration
CodeChef solution KITCHENTIME - Kitchen Timings Codechef solution in C, C++