2021年1月25日星期一

Determine a function to extract the individual digits of a long data type in c without using arrays and use only loops or conditionals

i am trying to determine a function to extract the individual digits of a long data type which the user enters.

**int remain(int digit)  {      while(number != 0)      {          digit = number % 10;          number = number / 10;      }      return digit;  }**  

in this code the number variable is the number entered by user. i want to extract all the digits of the number (e.g. a 16 digit number). so when i print remain(16) it prints 16 instead of 16th digit or prints 1 if i print remain(1) and also, it prints the first digit if the number is less than 13 or or greater than 16 and prints the 1 or 2 or 3 if i print remain(1) or remain(2) or remain(3) instead of printing the 1st or 2nd or 3rd digit

https://stackoverflow.com/questions/65895128/determine-a-function-to-extract-the-individual-digits-of-a-long-data-type-in-c-w January 26, 2021 at 10:30AM

没有评论:

发表评论