How to subtract the last digit of a number from the same number in C

1 Answer

0 votes
#include <stdio.h>

int main(void) {
    int n = 8405796;
    printf("n: %d\n", n);

    n = n - n % 10;
    
    printf("n: %d\n", n);
    
    return 0;
}


  
/*
run:
  
n: 8405796
n: 8405790
 
*/

 



answered Jan 15, 2021 by avibootz
...