0
How to input big integer in C?
I want to take input a 100 digit number and then want to divide by 3.. How can I do this?
7 Antworten
+ 3
Here's my code...
Check it...
https://code.sololearn.com/cKWk4rRePC3E/?ref=app
+ 6
One way of doing it is with structure lists, such as a stack. Basically, you should create a structure which will store a digit of the input number and a link to the next structure which stored the next digit. It can also be helpful to store address of the previous digit structure.
Using the division algorithm, you can actually perform the division, by going through the digits just as you would do by hand. Each resulting digit should be stored in a new stack.
It is helpful to create functions which will take the stack and print it, or which will add a digit dynamically, and so on. Maybe it's best that you start by doing a sum function, which returns a new dynamically allocated stack storing the result. Then move on to the division procedure.
I've already done something like this, and the way is indeed with structure stacks.
Hope that was helpful!
+ 5
Yes you can, but there isnt any build-in library for that in C, if you can use java's bigInteger for simplicity otherwise you have to write it code by your own which is time consuming and hard, maybe you should search for pre-wrriten BigInteger manupliation code for C language in Google
+ 1
you need to save the number as a string and do divisions as a string
here is a way to do it
https://www.google.com/amp/s/www.geeksforgeeks.org/divide-large-number-represented-string/amp/
0
First of all you have to take the number input in a char array because int will overflow....
Then make a function which will divide it the same way as we divide a number on a notebook, we have to simulate the same prosiser in the form of code...
if you want the code of that divide function... i will provide... ask me...
0
Hope this will help
- 2
You can use long or double int