Questions tagged [digits]

Questions dealing with getting, manipulating, or changing the digits of numbers

Use this tag for questions dealing with getting, manipulating, or changing the digits of numbers. More about digits on wikipedia

1098 questions
-3
votes
1 answer

why n mod 10 in loop doesn't show output

I have solve a basic problem in c that is count the digits in integer and I have written - #include int main() { int n; scanf("%d",&n); int i; while(n!=0) { n %= 10; ++i; } …
-3
votes
2 answers

How can I keep the last 6 digits number in c#

If I copy " BOB3 27QK DEPM PJ7J T25G SJZI CJA5 BO5O|123456 " and I want to pass it to my text box, and get only the last 6 digits number in my text box, How to do in c#?
-3
votes
2 answers

Input 12 digit number and save as int. C

I am new to C and memory allocation. I am trying to take a 12 digit input and save as int so later on I can do some calculations. So far I have: #include void main(void){ char number[12]; do { printf("Credit Card…
SomeGuy
  • 89
  • 1
  • 9
-3
votes
4 answers

If the String has number inside then square the number and return as a String. How do i replace old number with the squared number Java

So it should work like that squareDigits("a22b") on "a44b" squareDigits("a9b2") on "a81b4" What I have got so far : public class Code { public static void main(String[] args) { String ok = "a2b9"; …
-3
votes
1 answer

Digit Square Sum

Dr Phan has found that by performing digitSquareSum() multiple times, two numbers get back to their original number: • 1 -> 1 • 89 -> 145 -> 42 -> 20 -> 4 -> 16 -> 37 -> 58 -> 89 She asked Ken to identify which of the original numbers, between 1…
-3
votes
1 answer

How to check if the entered character is a digit?

Given task is: Enter 10 characters. For each character entered the corresponding function prints whether it is a digit 0-9 or not.(Also I use older compiler if anyone concerns about my "gets()" and goal is to do this without pointers.) So far I…
-3
votes
1 answer

How to remove c digits in an n number?

I have written a P function that removes c digits in an n integer number. The head of the function is : void P(int &n, int &c). Let's say n = 23734 and c = 3 The output should be: 274 This what i have tried before asking here. void P(int &n,int…
-3
votes
3 answers

The converted floating to decimal point?

In case x = 0.898558 #float with zero prefix I tried from decimal import Decimal x = 0.898558 print(Decimal(x)) Output: 0.898557999999999967855046634213067591190338134765625 I think i can do something and i tried x = 0.898558 print('%.2f' %…
alnyz
  • 91
  • 1
  • 1
  • 9
-3
votes
1 answer

Extract significant digit from 0.0007

I want to extract significant digit of 7 from XX=0.0007 The code is as follows XX=0.0007 enX1=XX//10**np.floor(np.log10(XX)); But XX becomes 6not 7. Can anyone help me?
-3
votes
2 answers

c++ how to check each digit in an integer and compare it to the base number

I am having trouble figuring out how to separate each digit in an integer number. Basically, I have to ask the user what the base number is, and then ask them for two integer numbers. Now, I have the task of checking to make sure each digit in the…
xxrachh
  • 1
  • 3
-3
votes
2 answers

Sum of digits from a string - Javascript

Any help with the below. The function should take any string with a jumble of letters and numbers. It should add together all the numbers that appear in the string and return the total. E.g. 'foo5bar6cat1' => 12 'foo98cat' => 17 I have tried the…
Vuweveka
  • 9
  • 3
-3
votes
1 answer

Control digits in specific cells

I have a table that looks like this: +-----------------------------------+-------+--------+------+ | | Male | Female | n | +-----------------------------------+-------+--------+------+ | way more than my fair…
b_schmidl
  • 81
  • 7
-3
votes
2 answers

Manipulate this code so that it counts the # of digits in a file

I need to manipulate this code so that it will read the # of digits from a file. I am honestly stumped on this one for some reason. Do i need to tokenize it first? Thanks! import java.io.*; import java.util.*; public class CountLetters { …
Kitty
  • 1
-3
votes
3 answers

checking a digit in a character array using pointer giving me an error in c giving me runtime error

char c[100]; char *pc; pc = c; printf("Enter the string:\n"); gets(c); while(*pc != '\0') { if(isdigit(*pc)==1) printf("%c",*pc); pc++; } why this program is not giving the output since it gives no errors while executing, please…
-3
votes
1 answer

Scanner.hasNextLong Error

Hello and thanks in advance, I'm having a problem with the java.util.Scanner Here is my code: public static void ScanInput(String Choice) { if(scanner.hasNextLong()){ long input = scanner.nextLong(); long length =…
Neriesta
  • 41
  • 3