Physical Address

304 North Cardinal St.
Dorchester Center, MA 02124

Final Population CodeChef Solution

Problem – Final Population CodeChef Solution

There were initially X million people in a town, out of which Y million people left the town and Z 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 T, denoting the number of test cases.
  • The first and only line of each test case consists of three integers XY and Z.

Output Format

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


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

Sample 1:

Input: 4
3 1 2
2 2 2
4 1 8
10 1 10
Output: 4


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

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

Final Population CodeChef Solution in C++14

using namespace std;
int main(int argc, char const *argv[])
    int n,x,y,z;
    while (n--)
        if (x>=y)

Final Population CodeChef Solution in Java

import java.util.*;
import java.lang.*;

class Codechef
	public static void main (String[] args) throws java.lang.Exception
		Scanner sc = new Scanner(;
		int a = sc.nextInt();
		    int x = sc.nextInt();
		    int y = sc.nextInt();
		    int z = sc.nextInt();
		    int a1 = x-y;
		    int a2 = a1+z;

Final Population CodeChef Solution in Pyth 3

x = int(input())
for i in range(x):
    a,b,c = map(int,input().split())
    z = a-b
    y = z+c
Final Population CodeChef Solution Review:

In our experience, we suggest you solve this Final Population CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the Final Population CodeChef Solution

Find on CodeChef


I hope this Final Population CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions

Leave a Reply

Your email address will not be published. Required fields are marked *