Answers for "factore of 20 in c+"

C++
1

factore of 20 in c+

#include <iostream>
using namespace std;

int main() {
    int n, i;

    cout << "Enter a positive integer: ";
    cin >> n;

    cout << "Factors of " << n << " are: ";  
    for(i = 1; i <= n; ++i) {
        if(n % i == 0)
            cout << i << " ";
    }

    return 0;
}
Posted by: Guest on October-24-2021

Browse Popular Code Answers by Language