# Percentage Calculation – C++ Projects – Mini Project Hey! Welcome Students, We will teach you and provide you Percentage Calculation C++ Projects, So, I make it an easy way, And Yo will be able to understand C++.

We made CS201 Assignment 2 Solution 2020 Which we Calculate the Percentage of Death and Recovered persons from Covid_19.

But we using Three Functions of C++ Cplusplus. Then the name of Functions:

• showElements();
• second function “PercentageDeath();”
• the third function: PercentageRecovered();

## At this time we will solve Five Questions.

1. First is, So, to fill/populate a two-dimensional array using given source data.
2. the Second is, So, Why to write user-defined functions and pass an array to them as a parameter.
3. third is, Then, what is to use if statement and do while loop.
4. Fourth is, Then, How to calculate the percentage in elements of an array.
5. fifth is, Then, and to display array elements.

## C++ Projects Requirments (Percentage Calculation)

So, This C++ Program’s function uses the void data_type and this data type is not returning any values. Then these functions return Two dimensional Array.

The first function takes one argument. and Then take Two-dimensional array like this long/int data-type with int myar[ ], and the 2nd and 3rd function takes two arguments.

In this way, So, one argument likes the first function argument and another argument is data-type int I;

Another hand the 3rd function same use the arguments from function two.
given data is:

Below, Watch this Video How I made this program with voice and Examples in Urdu and Hindi. and Learn Percentage Calculation C++ Projects and do hard work and a lot of practics.

``````#include <iostream>
using namespace std;
void showElements(long myar[]);
void percentageDeath(long myar[], int i);
void percentageRecovered(long myar[], int i);
int main()
{
int codeCount;
long myData =
{
{0, 560433, 22115, 32634},
{1, 156363, 19899, 34211},
{2, 84279, 10612, 0},
{3, 82160, 3341, 77663},
{4, 71686, 4474, 43894},
{5, 56956, 1198, 3446},
{6, 5374, 93, 1095}
};
showElements(myData);
do{
cout << "Press the country code to calculate percentage of dead and recovered persons" << endl;
cout << "Press 0 for Pakistan." << endl;
cout << "Press 1 for China." << endl;
cout << "Press 2 for Italy." << endl;
cout << "Press 3 for UK." << endl;
cout << "Press 4 for Iran." << endl;
cout << "Press 5 for France." << endl;
cout << "Press 6 for Turkey." << endl;
cout << "Press 7 to exit." << endl;
cout << "Please select an option, use numbers from 0 to 7 :";
input:
cin >> codeCount;
if(codeCount>=0 && codeCount<=6)
{
percentageDeath(myData, codeCount);
percentageRecovered(myData, codeCount);
}
else if(codeCount<0 || codeCount>7)
{
cout<<"Choice should be between 0 to 7 " << endl;
cout<<"invalid choice ! please select again : ";
goto input;	// This statement is forwording the flow of program to line no 31
}
}while(codeCount!=7);
}
// Here started the showElements() function...
void showElements(long myar[]){
cout << "Source Data: " << endl;
cout << '\n';
cout << "Country" << " Cases" << "   Deaths" << "  Recovered" << endl;
cout << '\n';
int i, j;
for(i = 0; i < 7; i++)
{
for(j = 0; j < 4; j++)
{
int temp;
temp = myar[i][j];
cout<< myar[i][j] << '\t';
}
cout << endl ;
}
cout << '\n';
cout << '\n';
}
// Start the PercentageDeath Function...
void percentageDeath(long myar[], int i)
{
double deathRate=(double)100*myar[i]/myar[i];
cout<<"Percentage of deaths is: "<< deathRate << '\n' << '\n';
}
// End the PercentageDeath Function.
// Start the PercentageRecovered Function...
void percentageRecovered(long myar[], int i)
{
double recoveredRate=(double)100*myar[i]/myar[i];
cout<<"Percentage of recovered is: "<< recoveredRate <<"\n";
}``````

So, your students will be able to make your own C++ program after Learning this. But you have to pay heed to your Work.

Summery, So, I have covered the CS201 Full and true assignment solution of 2020. because its a demand of our some students. 