Open

0

# How to perform mathematical operations on number represented as string in c++? How do I store number larger than c++ numerical?

C++ question

2 Answers

+ 1

In order to deal with huge numbers, you can either use a custom user defined datatype ( string , arrays etc ) to store them and then create functions to perform calculation on them manually or use an external library like gnu's multiple precision arithmetic library to do that for you.
Here's a simple implementation of bignum calculator used to calculate value of large Fibonacci numbers that I created for one of the community challange here on SL ðŸ‘‡
https://code.sololearn.com/c7iD3WKd84RP/?ref=app

0

#include<stdio.h>
int main()
{
const char *str = "12345";
int x;
sscanf(str, "%d", &x);
printf("\nThe value of x : %d", x);
return 0;
}