#include <iostream>
using namespace std;

int main() {
    int x;
    cout<<"enter a number = "<<endl;
    cin>>x;
    if (x%3==0 && x%5==0){
        cout<<"number is diviible by both 5 and 3"<<endl;
    }
        
    else if (x%3==0) {cout<<"divisible by 3 only "<<endl;
                     }
    else if (x%5==0) {                            //here we can use else if statement 2 times due to which the output doesnt conflict with the last statement due to the input
        cout<<"divisible by 5 only"<<endl;
    }
        
    }

Embed on website

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