Question: Using c++ language. Please correct all paragraphs Q1: Do the red color lines in the given code below Attach your code below Then give all
Using c++ language. Please correct all paragraphs
Q1:
Do the red color lines in the given code below
Attach your code below
Then give all your output, as mentioned In red color in main()
Sample code:
#include
using namespace std;
const int CITY_NO = 5;
float Volt[CITY_NO];
float Cur[CITY_NO];
float Pow[CITY_NO];
void input_volt(void)
{
int i;
for(i=0; i { cout << "Enter voltage for city " << i << ": "; cin >> Volt[i]; } } // write a similar function input_current() // to input current for all cities one by one // and store in Cur[] array // give realistic values as input currents and input voltages // write a function calculate_power() // to calculate Pow[i] = Volt[i]*Cur[i] // and store in Pow[i] array void output_volt(void) { int i; for(i=0; i { cout << "Voltage of City " << i << ": " << Volt[i]; cout <<" "; } } //write similar functions for output all city current // write similar function for output all city power void max_volt() { int max, i, max_city; max = Volt[0]; max_city = 0; for(i=1; i { if(Volt[i] > max) { max = Volt[i]; max_city = i; } } cout << "Maximum voltage: " << max; cout << " in city " << max_city; } //write similar functions for output maximum current and that city number // write similar function for output maximum power and that city number void sum_avg_volt(void) { int i; float sum, avg; sum = 0; for(i=0; i { sum = sum + Volt[i]; } avg = sum/CITY_NO; cout << "Average voltage: " << avg; } //write similar functions for output average current // write similar function for output average power void city_volt() { int x; cout << "Enter city number to see its voltage: "; cin >> x; cout << "Voltage of city " << x << ": " << Volt[x]; } //write similar functions for output city current // write similar function for output city power int main(void) { input_volt(); //input_current(); output_volt(); //output_current(); //output_power(); city_volt(); //city_current(); //city_power(); max_volt(); //max_current(); //max_power(); sum_avg_volt(); //sum_avg_current(); //sum_avg_power(); } Sample output: Put your code here: Put your screen picture here:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
