Question
In C Programming Please, Not C++ ______________________________________________________________________________________________ Write a complete C programming to add two very large numbers together as follows: ______________________________________________________________________________________________ Enter the first number 1999999999999999999999999999999999999999999996667766999999 ______________________________________________________________________________________________ Enter the second number 888888888888888888888888888888888888888888888888888888888888888888888888 ______________________________________________________________________________________________ Sum is Display the total here ______________________________________________________________________________________________ Hint you should use Struct and malloc.
Explanation / Answer
#include #include int main (void) { int i=0,k=0; int tmp1=0, tmp2=0, tmp3=0; char * a; a= (char *) malloc(30 * sizeof(char)); char * b; b= (char *) malloc(30 * sizeof(char)); int * x; x= (int *) malloc(30 * sizeof(int)); int * y; y= (int *) malloc(30 * sizeof(int)); int * z; z= (int *) malloc(61 * sizeof(int)); int * w; w= (int *) malloc(31 * sizeof(int)); int * v; v= (int *) malloc(61 * sizeof(int)); int * solution; solution= (int *) malloc(61 * sizeof(int)); int carry = 0; int c[61]; int d[61]; int f[61]; int g[61]; printf(" Enter a number (up to 30 digits in length)> "); scanf("%s", a); i=0; while(i = 0; i--) { for(k=60; k>=0; k--) { tmp1 = f[i] * g[k]; z[k] = tmp3 + z[k-1]; tmp3 = tmp1 % 10; z[k-1]= tmp1 / 10; } } for(i = 0; i < 61; i++){ printf("%d", z[i]);} printf(" "); return(0); } i added the multiplication part also dont get confused