How to get the last digit of int number in C++

1 Answer

0 votes
#include <iostream>

using namespace std;

int main() 
{ 
    int n = 9286, last_digit;
 
    last_digit = n % 10;

    cout << last_digit;

    return 0; 
}   
       
       
 
       
/*
run:

6
     
*/

 



answered Aug 27, 2019 by avibootz

Related questions

1 answer 93 views
1 answer 195 views
195 views asked Aug 24, 2019 by avibootz
1 answer 211 views
1 answer 163 views
1 answer 205 views
1 answer 173 views
1 answer 157 views
...