Answer to Question #188395 in C++ for naura

Question #188395

using counter-loop structure, write a program segment to accept the weight of 100 students. the program counts and displays the number of students whose weight is more than 75 kilograms


1
Expert's answer
2021-05-03T08:50:40-0400
#include <iostream>


int main()
{
    // simple counter-loop example
    float weight{ 0 };
    int count_people{ 1 };
    int count_weight{ 0 };
    while (count_people <= 100) 
    {
        std::cout<<"Enter the weight of the " <<count_people<<"  students: ";
        std::cin >> weight;
        if (weight > 75) {
            count_weight += 1;
        }
        count_people += 1;
    }
    std::cout << "Number of students weighing more than 75 kgn" << count_weight << std::endl;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS