C++ Chapters

C++ Program for the right most digit of a number.

Structure of C++ Programs - Overview
#include <iostream>
using namespace std;

int main()
{
    int Num, Right_Num;
    
    cout << "Enter Number : ";
    cin >> Num;
    
    Right_Num = Num % 10;
    
    cout << "\n\nThe right most digit is : " << Right_Num;
    
    return 0;
}

Output :
Enter Number : 123

The right most digit is : 3

Description :

Modulo (%) operator gives reminder of division of two numbers.
So Reminder of 123/10 is 3 the right most digit.


Leave a comment
Recent Comments
No Comments