Write a program to add or subtract two big integer numbers. “Big” refers to a number which is more than 30 digits. You can assume that the number may have MAXIMUM 100 digits. Your program should have the data structures to hold such a big number. Also it should have two functions viz Add and Subtract and a main function which demonstrates the usage of Add and Subtract.

e.g of one such operation 12334444446666666666888888812233 + 2222227889999999999 = 12334444446668888894778888812232...

can anyone help me how to solve this problem or how to approach this problem...
its urgent if any sample code or any related url so plz forward it...
Thanks in Advance..

Prashnat

make a fuction out of this program and brint to use

#include<iostream>
#include<string>

using namespace std;
int main()
{	
	int l1,k=0, i, l2,j,p; 
	char s_num1[110], s_num2[110], s_ans[111]; 
	int tens=0, ones, ans;
	cin>>s_num1;
	cin>>s_num2;
	//cout<<(int) s_num1[0];
	for(l1=0;s_num1[l1]!='\0';l1++);
	for(l2=0;s_num2[l2]!='\0';l2++);
	l1--;
	l2--;
	for(i=l1, j = l2;(i>=0)&&(j>=0);i--,j--){
		ans = (int) s_num1[i] + (int) s_num2[j] + tens - 2*48;
		ones=ans%10;
		tens=ans/10;
		s_ans[k] = ones + 48;
		k++;
	}
	
	while(i>=0){
		cout<<"str 1 bigger\n";
		ans = tens + (int) s_num1[i] -48;
		ones=ans%10;
		tens=ans/10;
		s_ans[k] = ones + 48;
		k++;
		i--;
	}
				
	while(j>=0){
		cout<<"str2 biigger\n";
		ans = tens + (int) s_num2[j] -48;
		ones=ans%10;
		tens=ans/10;
		s_ans[k] = ones + 48;
		k++;
		j--;
	}

	if(tens!=0)
		s_ans[k++] = tens+48;	
		

	cout<<k<<endl;
	for(p=k-1;p>=0;p--)
		cout<<s_ans[p];
	
	return 0;
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.