Question

In: Computer Science

Write up to 10 lines to explain the logic used behind this code pls!!!!! #include <iostream>...

Write up to 10 lines to explain the logic used behind this code pls!!!!!

#include <iostream>

#include <iomanip>

#include<cmath>

#include<AclUI.h>

using namespace std;

int main()

{

    int array[][2] = { {29,60} , {33,80} , {45,90} , {57,52} , {12,44} , {21,78} , {32,64} , {17,59} }; //given values

    int Totalstudents = 0,TotalPass = 0, Average = 0;

    for (int i = 0; i < 8; i++)      //students enrooled

    {

         Totalstudents += array[i][0];

    }

    for (int i = 0; i < 8; i++)      //Total Pass

    {

         TotalPass += array[i][1];

    }

    TotalPass /= 8;

    for (int i = 0; i < 8; i++)      //Loop to calculate total students passed

    {

         Average += int(((array[i][0] * array[i][1]) / 100));

    }

    //Display the results

    cout << "Name of Paper" << setw(25) << "               Students Enrolled" << setw(15) << "Passed %" << setw(35) << "                 Number of Passing Students" << endl;

    cout << "Architecture" << setw(25) << array[0][0] << setw(15) << array[0][1] << setw(35) << int(0.60 * array[0][0]) << endl;

    cout << "Computing   " << setw(25) << array[1][0] << setw(15) << array[1][1] << setw(35) << int(0.80 * array[1][0]) << endl;

    cout << "Electrical " << setw(25) << array[2][0] << setw(15) << array[2][1] << setw(35) << int(0.90 * array[2][0]) << endl;

    cout << "Mechanical " << setw(25) << array[3][0] << setw(15) << array[3][1] << setw(35) << int(0.52 * array[3][0]) << endl;

    cout << "Chemical    " << setw(25) << array[4][0] << setw(15) << array[4][1] << setw(35) << int(0.44 * array[4][0]) << endl;

    cout << "Biomedical " << setw(25) << array[5][0] << setw(15) << array[5][1] << setw(35) << int(0.78 * array[5][0]) << endl;

    cout << "Mechatronics" << setw(25) << array[6][0] << setw(15) << array[6][1] << setw(35) << int(0.64 * array[6][0]) << endl;

    cout << "Electronics " << setw(25) << array[7][0] << setw(15) << array[7][1] << setw(35) << int(0.59 * array[7][0]) << endl;

    cout << "Total       " << setw(25) << Totalstudents << setw(15) << TotalPass << setw(35) << Average << endl;

    return 0;

}

Solutions

Expert Solution

Answer :

This program is mainly used to calculated the statistics of student exams in 8 different papers


Below is the steps used to calculate statistics :


1.Including required libraries and declaring required variables.
2.Initilized 2-D array containing total students and total pass percentage for each paper.
3.There are 8 fields(Architecture,computing etc...) so 8 papers.
4.Using Loop to calculate total students enrooled for 8 papers.
5.Using another for loop to sum all the pass percentages in 8 papers.
6.Then dividing the sum with 8 to get Total Pass percentage.
7.In Output they are using setw() function to format the output and printing it in correct order(In tabular form).
8.printing the Name of Paper,Students Enrolled,passed %,Number of passing Students for all 8 Papers(Well formated).
9.Number of passing Students = numOfStudents*(pass percentage/100)
10.At final they are printing the already calculated totalStudents,TotalPass and average for total 8 fields.

********Comment me for any Quereis and Rate me up*********


Related Solutions

Write up to 10 lines to explain the logic used behind this code pls!!!!! *****************************************/ #include...
Write up to 10 lines to explain the logic used behind this code pls!!!!! *****************************************/ #include <iostream> #include <string> #include <iomanip> #include<activaut.h> #include<activdbg.h> using namespace std; int main() {     int MatchesPlayed[6], MatchesWon[6], MatchesLost[6], MatchesDraw[6], MatchesPoints[6], TotalPoints[6];     MatchesWon[0] = 3; MatchesLost[0] = 0; MatchesDraw[0] = 1; //India     MatchesWon[1] = 2; MatchesLost[1] = 0; MatchesDraw[1] = 1; //NZ     MatchesWon[2] = 0; MatchesLost[2] = 3; MatchesDraw[2] = 0; //Australia     MatchesWon[3] = 1; MatchesLost[3] = 2; MatchesDraw[3] = 1;...
Write up to 10 lines to each code explain the logic used behind these code pls!!!!!...
Write up to 10 lines to each code explain the logic used behind these code pls!!!!! (10 lines for each please) 1. #include<iostream> using namespace std; int main() {        int id, reverse[20], count = 0, min = 0, max = 0;        cout << "\nStudent ID Number is \n";        cin >> id;        while (id != 0)        {              reverse[count] = id % 10;              if (count == 0)              {                     min = reverse[count];                     max...
Write up to 4 or 5 lines to explain the logic used behind those codes. Separately...
Write up to 4 or 5 lines to explain the logic used behind those codes. Separately for each please 1) #include <iostream> #include <string> #include <fstream> #include <vector> #include <sstream> using namespace std; int main() {         ifstream infile("worldpop.txt");         vector<pair<string, int>> population_directory;         string line;         while(getline(infile, line)){                 if(line.size()>0){                         stringstream ss(line);                         string country;                         int population;                         ss>>country;                         ss>>population;                         population_directory.push_back(make_pair(country, population));                 }         }         cout<<"Task 1"<<endl;         cout<<"Names of countries with population>=1000,000,000"<<endl;...
write the algorithm for this the code?!. #include<iostream> using namespace std; #include<string.h> int main() { char...
write the algorithm for this the code?!. #include<iostream> using namespace std; #include<string.h> int main() { char plain[50], cipher[50]="", decrypt[50]=""; int subkeys[50], len;       cout<<"Enter the plain text:"<<endl; cin>>plain;    cout<<"Enter the first subkey:"<<endl; cin>>subkeys[0];    _strupr(plain);    len = strlen(plain);    /**********Find the subkeys**************/    for(int i=1; i<len; i++) { if ((plain[i-1]>='A') && (plain[i-1]<='Z')) { subkeys[i] = plain[i-1]-65; } }    /****************ENCRYPTION***************/       for(int i=0; i<len; i++) { if ((plain[i]>='A') && (plain[i]<='Z')) {    cipher[i] = (((plain[i]-65)+subkeys[i])%26)+65; }...
C++ code Why my code is not compiling? :( #include <iostream> #include <iomanip> #include <string> using...
C++ code Why my code is not compiling? :( #include <iostream> #include <iomanip> #include <string> using namespace std; const int CWIDTH = 26; int main() {    int choice;    double convertFoC, converCtoF;    double starting, endvalue, incrementvalue;    const int CWIDTH = 13;    do {       cin >> choice;    switch (choice)    {        cin >> starting;    if (starting == 28){       cout << "Invalid range. Try again.";    }    while (!(cin >> starting)){       string  garbage;       cin.clear();       getline(cin, garbage);       cout << "Invalid data Type, must be a number....
C++ CODE ONLY Using the following code. #include <iostream> #include <string> #include <climits> #include <algorithm> using...
C++ CODE ONLY Using the following code. #include <iostream> #include <string> #include <climits> #include <algorithm> using namespace std; // M x N matrix #define M 5 #define N 5 // Naive recursive function to find the minimum cost to reach // cell (m, n) from cell (0, 0) int findMinCost(int cost[M][N], int m, int n) {    // base case    if (n == 0 || m == 0)        return INT_MAX;    // if we're at first cell...
Complete the following TODO: parts of the code in C++ #include <iostream> #include <string> #include <limits>...
Complete the following TODO: parts of the code in C++ #include <iostream> #include <string> #include <limits> #include <vector> using namespace std; // // CLASS: NODE // class Node{ public: int value = 0; // our node holds an integer Node *next = nullptr; // our node has a pointer to the next Node Node(int i){ // contructor for our Node class value = i; // store a copy of argument "i" in "value" next = nullptr; // be sure next...
make the following "swap" working corretly, write the missing code at line 14. #include <iostream> using...
make the following "swap" working corretly, write the missing code at line 14. #include <iostream> using namespace std; void swap(int& x, int& y) { int z = x; x =y; y=z; } int main () { int a= 45, b =35; cout<<" before swap\n"; cout<<"a = " << a << "b = " << b<< "\n"; ________________________ cout << "After swap with pass by reference\n"; cout << "a = " << a << " b = " << b <<...
--- TURN this Code into Java Language --- #include <iostream> #include <string> using namespace std; //...
--- TURN this Code into Java Language --- #include <iostream> #include <string> using namespace std; // constants const int FINAL_POSITION = 43; const int INITIAL_POSITION = -1; const int NUM_PLAYERS = 2; const string BLUE = "BLUE"; const string GREEN = "GREEN"; const string ORANGE = "ORANGE"; const string PURPLE = "PURPLE"; const string RED = "RED"; const string YELLOW = "YELLOW"; const string COLORS [] = {BLUE, GREEN, ORANGE, PURPLE, RED, YELLOW}; const int NUM_COLORS = 6; // names...
Please write variables and program plan(pseudocode) of this C++ programming code: #include <iostream> using namespace std;...
Please write variables and program plan(pseudocode) of this C++ programming code: #include <iostream> using namespace std; void leapYear(int x); int main() { int x; cout << "Enter a year: "; cin >> x; leapYear (x);   return 0; } void leapYear(int x ) {    if (x % 400 == 0)    {    cout << "This is a leap Year";}    else if    ((x % 4 == 0) && (x % 100 != 0))    {    cout <<...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT