#include <iostream>
using namespace std;

int main() {
      int n;
    cout << "Enter a number: ";
    cin >> n;
    for (int i = n/2 ; i>=1 ; i--) {
        if (n%i==0);
        {
            cout << i << " ";
            break; // it means to getr out of the loop immediately
        }
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: