mercredi 4 octobre 2017

Why isn't this simple for loop working C++?

This is my code to find the multiples of a number. But it doesn't output the multiples.

#include "stdafx.h"
#include <iostream>
using namespace std;

int main()
{ 
cout << "Enter the number:" << endl;
int num;
cin >> num;
for (int i=1; i == num; i++) {
    if ((num % i) == 0) {
        int res = num / i;
        cout << num << " divided by " << i << "=" << res << endl;
    }
}
return 0;
}

Aucun commentaire:

Enregistrer un commentaire