Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  1
Language: C/C++
Code:
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<string.h>

char num1[100],num2[100];
int m=strlen(num1), n=strlen(num2),i,j,k=0,carry=0;
int result[101];               

while(i>=0 && j>=0){
result[k++]= ((num1[i]-'0')+(num2[j]-'0')+carry) % 10;

carry=((num1[i]-'0')+(num2[j]-'0')+carry) / 10;
i--;j--;
}
if(i>=0){  
while(i>=0){
result[k++]=(num1[i]-'0' + carry)%10;
carry=(num1[i] - '0' +carry)/10;
i--;
}
}
if(j>=0){           
while(j>=0){
result[k++]=(num2[j]-'0'+ carry)%10;
carry = (num2[j] - '0' + carry)/10;
j--;
}
}
if(carry){          
result[k++]=carry;}

k--;
for(;k>=0;k--)
printf("%d",result[k]);
          
          
          
          
          
          
          
          
Comments: