Wednesday 9 March 2016

Splitting into Teams


During the Physical Education hour, PD sir Mr. Sundar has decided to conduct some team games. He wants to split the students in the class into equal sized teams. In some cases, there may be some students who are left out from teams and he wanted to use the left out students to assist him in conducting the team games. For instance, if there are 50 students in the class and if the class has to be divided into 7 equal sized teams, 7 students will be there in each team and 1 student will be left out. PD sir asks your help to automate this team splitting task. Can you please help him out?

Input Format:

Input consists of 2 integers. The first integer corresponds to the number of students in the class and the second integer corresponds to the number of teams.

Output Format:

Refer sample input and output for formatting specifications.

Sample Input and Output:
[All text in bold corresponds to input and the rest corresponds to output]
Enter the number of students in the class
 60
Enter the number of teams
8
The number of students in each team is 7 and the number of students left out is 4

Code:
  #include<stdio.h>
int main(){
  int n,t,cal=0, call;
  printf("Enter the number of students in the class\n");
  scanf("%d",&n);
  printf("Enter the number of teams\n");
  scanf("%d",&t);
  cal=n/t;
  call=n%t;
  printf("The number of students in each team is %d and the number of students left out is %d",cal,call);
  
  return 0;
}

No comments:

Post a Comment