Haneef Puttur

C++ Program to Display Numbers 1 to 100 , Multiples of 4 but Not Divisible by 5

#include <iostream>
#include <string>
using namespace std;
int main()
{
 for (int k =0; k <=100; k=k+4)  // Run a for loop in steps of 4
 {
 while( k % 5 != 0)  // check if divisble by 5
 {
 cout << k << endl;
 break;                    // Exit while loop to avoid infinite loop
 }
 
 }
 
 return 0;
 
 
}
Exit mobile version