Meme detail
About this meme
Text detected in the image
How to assign a value of 10^100 to an integer variable in C? Asked 7 years, 11 months ago Modified 7 years, 11months ago Viewed 913 times I was working on a problem to count number of digits in a number but according to the constraints the number should be of the range 10^100(10 to the power 100). I have tried it using limits.h but it 1 did not work. Could anyone suggest a way to do that? int main(){ □ int n=LONG_MAX; int count; 2 scanf("%d", &n); while(n!=0) { n=n/10; count++; } printf("%d",count); return 0; } c Share Improve this question Follow edited Jun 13, 2017 at 12:45 asked Jun 6, 2017 at 19:54 204401 dbush Neeraj Sewani 228k •25 249 321 4,3177 42 •57 1 If you have the number as text, you can just count its digits directly. Otherwise you are going to need a "biqnum" library, 10^100 is well beyond the range of any built-in inteqer type. - zwol Jun 6, 2017 at 19:56 You can use the GMP gmplib.org to work with big integers in C and C++ - Pedro Henrigue Jun 6. 2017 at 19:56 1 10^100is guaranteed to fit a Cint type. - user3185968 Jun 6, 2017 at 19:56 10 to the power of 100 in unsiqned integer representation requires 333 bits. You will need a library for indefinite integers. - Yunnosch Jun 6, 2017 at 19:56 4 "I was working on a problem to count number of digits in a number" -> show that code. "I have tried it using limits.h but it did not work. "-> show that code too. - chux Jun 6, 2017 at 20:11 Show 7 more comments 2 Answers Sorted by: Highest score (default) ÷ Well, in C 10^100 can be easily stored to anint 0 int xored = 10^100; After that,xoredwill store 110. □ 1100100 D 0001010 1101110