This is so basic yet i cant seem to get it and it is frustrating me Basically I need to input the world population and country population, and get what percentage the countries population is of the worlds. It seems so basic yet i cant get it.
This is what i have
#include <iostream>
using namespace std;
int main()
{
long long int worldPop, countryPop;
int ratio = 0.0;
string country;
cout <<"Enter the world population ";
cin >> worldPop;
cout <<"Enter the name of the country ";
cin >> country;
cout <<"Enter the population of the country ";
cin >> countryPop;
ratio = countryPop/worldPop;
cout <<"The population of "<< country << " is " << ratio <<"% of the world population";
return 0;
}
#include <iostream>
usingnamespace std;
int main()
{
longlongint worldPop, countryPop;
double ratio = 0.0;
string country;
cout << "Enter the world population ";
cin >> worldPop;
cout << "Enter the name of the country ";
cin >> country;
cout << "Enter the population of the country ";
cin >> countryPop;
ratio = double(countryPop) / double(worldPop) * 100;
cout << "The population of " << country << " is " << ratio << "% of the world population";
return 0;
}
#include <iostream>
int main()
{
longlongint worldPop {}, countryPop {};
std::string country;
std::cout << "Enter the world population ";
std::cin >> worldPop;
std::cout << "Enter the name of the country ";
std::cin >> country;
std::cout << "Enter the population of the country ";
std::cin >> countryPop;
std::cout << "The population of " << country << " is " << countryPop * 100.0 / worldPop << "% of the world population";
}