DevJourney · code I wrote while learning

README.md

1.1 KB

Single File Programming Question

Problem Statement

Write a program that allows Teju to input and manage population data for three cities. The program should allow users to input the names and populations of three cities.

Next, it calculates the total population of three cities and computes the average population using pointer arithmetic.

Input format :

For each of the three cities, the input consists of the following space-separate values:

The name of the city (a string) The population of the city (an integer)

Output format :

The first line displays an integer representing the total population of the three cities.

The second line displays a double value representing the average population of the three cities, rounded to two decimal places.

Refer to the sample output for the formatting specifications.

Code constraints :

1 ≤ Length of the city name ≤ 49

100 ≤ Population of each city ≤ 105

Sample test cases :

Input 1 :

Mexico 9200 Guadalajara 1460 Monterrey 1200

Output 1 :

11860 3953.33

Input 2 :

Mecca 14570 Dubai 34569 Toronto 12456

Output 2 :

61595 20531.67