Write a C++ program that should ask the user to input the final range up to which the loop should run and then prints ONLY the multiples of 5 (fully divided by 5 only), as

cpp programming exercise with solution
cpp programming exercise with solution

By using for loop

#include <iostream>
using namespace std;

int main()
{
int rang;
cout<<"Please enter a range upto which loop should run: ";
cin>>rang;
for (int i = 0; i<= rang; i++)
{
if (i % 5 == 0)
{
cout<<i<<endl;
}

}

return 0;
}


By using while loop

#include <iostream>
using namespace std;

int main()
{
int rang;
int i = 1;
cout<<"Please enter a range upto which loop should run: ";
cin>>rang;

while (i <= rang)
{
if (i % 5 == 0)
{
cout<<i<<endl;
}

}

return 0;
}