Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
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.
For each test case, output the final population of the town in millions.
Input: 4
3 1 2
2 2 2
4 1 8
10 1 10
Output: 4
2
11
19
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.
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
int n,x,y,z;
cin>>n;
while (n--)
{
cin>>x>>y>>z;
if (x>=y)
{
cout<<(x-y)+z<<endl;
}
else
{
break;
}
}
}
import java.util.*;
import java.lang.*;
import java.io.*;
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
while(a-->0){
int x = sc.nextInt();
int y = sc.nextInt();
int z = sc.nextInt();
int a1 = x-y;
int a2 = a1+z;
System.out.println(a2);
}
}
}
x = int(input())
for i in range(x):
a,b,c = map(int,input().split())
z = a-b
y = z+c
print(y)
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
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 >>