# Final Population Codechef Solution

Hello coders, today we are going to solve Final Population Codechef Solution whose Problem Code is POPULATION.

### Problem

There were initially XX million people in a town, out of which YY million people left the town and ZZ million people immigrated to this town.

Determine the final population of town in millions.

### Input Format

• The first line of input will contain a single integer TT, denoting the number of test cases.
• The first and only line of each test case consists of three integers XX, YY and ZZ.

### Output Format

For each test case, output the final population of the town in millions.

• 1≤T≤100
• 1≤X,Y,Z≤10
• Y≤X

Input
4
3 1 2
2 2 2
4 1 8
10 1 10

Output
4
2
11
19

### Explanation:

Test case 11: The initial population of the town was 33 million, out of which 11 million people left and 22 million people entered the town. So, final population = 3 – 1 + 2 = 4=3−1+2=4 million.

Test case 22: The initial population of the town was 22 million, out of which 22 million left and 22 million immigrated. The final population is thus 2+2-2 = 22+2−2=2 million.

### Final Population Codechef Solution in JAVA

```import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static Scanner sc=new Scanner(System.in);
public static void main (String[] args) throws java.lang.Exception
{
int t,n;
t=sc.nextInt();
while(t-- >0){
n=sc.nextInt();
int arr[]=new int[n];
for(int i=0;i<n;i++)
arr[i]=sc.nextInt();
Arrays.sort(arr);
for(int i=0;i<n;i++)
System.out.print(arr[i]+" ");
System.out.println();
}
}
}```

### Final Population Codechef Solution in CPP

```#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
sort(a,a+n);
for(int i=0;i<n;i++)
{
cout<<a[i]<<" ";
}
cout<<endl;
}
return 0;
}
```

### Final Population Codechef Solution in Python

```for i in range(int(input())):
n = input()
lst = list(map(int,input().split()))
lst.sort()
for i in lst:
print(i,end=" ")
print()```

Disclaimer: The above Problem (Final Population) is generated by CodeChef but the solution is provided by Chase2learn.This tutorial is only for Educational and Learning purpose.

Sharing Is Caring