Write a C++ program that will check whether the last digit of any integer number is divisible by 3 or not by taking user input.

#include <iostream>

using namespace std;

int main(){
    int x;

    cout << "Enter the Number: ";
    cin >> x;

    x %=10;

    if (x%3==0)
        cout << "Divisible";
        cout << "Not Divisible";

Enter the Number: 21
Not Divisible
Process returned 0 (0x0)   execution time : 4.639 s
Press any key to continue.

Previous Post Next Post