Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#include <iostream> using namespace std; int main() { double height[10]; int tal

ID: 3539270 • Letter: #

Question

#include <iostream>

using namespace std;

int main()

{

double height[10];

int tall=0;

for(int x=0;x<10;x++)

{

height[x] = 0.0;

}

cout<<"Enter the height of 10 students."<<endl;

for(int x=0; x<10; x++)

{

cout<< "Enter the height of the student: ";

cin>>height[x];

if(height[x]>60)

{

tall++;

}

}

cout<<"Number of students taller than 60 inches: "<<tall<<endl;

}


Modify your program in Program 1 (code above). In addition to count and display the number of students taller than 60 inches, also count and display the number of students shorter than 55 inches.   

Explanation / Answer

#include <iostream>

using namespace std;

int main()

{

double height[10];

int tall=0;

int small = 0;

for(int x=0;x<10;x++)

{

height[x] = 0.0;

}

cout<<"Enter the height of 10 students."<<endl;

for(int x=0; x<10; x++)

{

cout<< "Enter the height of the student: ";

cin>>height[x];

if(height[x]>60)

{

tall++;

}

else if(height[x]< 55)

{

small++;

}

}

cout<<"Number of students taller than 60 inches: "<<tall<<endl;

cout<<"Number of students shorter than 55 inches: "<<small<<endl;

}