Computer Science, asked by joglekaraashay, 2 days ago

Write a C++ program (using while loop) to display all the multiples of 5 from 100 to 50.​

Answers

Answered by anindyaadhikari13
9

Solution:

The given problem is solved in C++

#include <iostream>

using namespace std;

int main() {

   int i = 100;

   while (i >= 50){

       cout << i << " ";

       i -= 5;

   }

   return 0;

}

Explanation:

  • At first, we have initialised i = 100.
  • Then a while loop is created which iterates when i >= 50.
  • Inside the loop, the value of i is displayed.
  • Then the value of i is decreased by 5 since multiples of 5 are at interval of 5 numbers.


Refer to the attachment for output.

Attachments:
Similar questions