How to get the last digit of int number in C

1 Answer

0 votes
#include <stdio.h> 
      
int main() 
{ 
    int n = 723489;
 
    int last_digit = n % 10;
 
    printf("%d", last_digit);
        
    return 0; 
} 
      
      
      
/*
run:
      
9
    
*/

 



answered Aug 24, 2019 by avibootz
edited Mar 7, 2024 by avibootz

Related questions

1 answer 190 views
1 answer 211 views
1 answer 163 views
1 answer 205 views
1 answer 172 views
1 answer 157 views
1 answer 138 views
...