Here's another hint: think of how you do addition by hand. You would add one column of digits, carrying over if needed.
Printable View
Here's another hint: think of how you do addition by hand. You would add one column of digits, carrying over if needed.
ya i know i have to solve it like that but i cant understand how to right that code
Try. Fail. Post code. We might fix it for you or tell you how to.
b quick buddies and i have one two more probs with my assignment acctually i have to calculate zakat of 500.98gram gold(24 carat)
and 2) how can i assign an array to another
You need to at least have a go yourself first. You can't just expect people to write the code for you.
Even if you're way off, have a go, post what you've done, then maybe you'll get some help.
and buddies what is that meaning e.d
a^b
how does it works"^"
ya i have tried all of them by my self but failed
Post your efforts.
Code:#include<stdio.h>
#include<conio.h>
#define MAXDIGITS 100
ch_to_bignum(char *s,bignum *n);
main()
{
clrscr();
typedef struct {
char digits[MAXDIGITS],
int signbit,
int lastdigit,
}bignum;
digits m1,m2;
printf("enter digits");
scanf("%c",m1);
printf("enter 2nd digit");
scanf("%c",m2);
ch_to_bignum(char*s,bignum*n);
getch();
}
ch_to_bignum(char*s,bignum*n)
{
int i;
if(s[0]!='-'
{
n->signbit='PLUS'
i=0;}
else
{i=1;
n->signbit='MINUS'
}
strcpy(n->digits,&s[i])
n->lastdigit=strlen(n->digits)
}
now i have to calculate 11111111111111111111111111111000000000000000000000 00000000000023333333333+45345789999999999999999992 43214444444444444444444444444444444444444440333333 3333333 as well as"-" and "*"
Quote:
Originally Posted by twomers
ok i will try my best but give me some hints that how can i add long ints by taking carry
this is not completeCode:#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
main()
{
clrscr();
int a[500];
int b[500];
int num1,num2,x,y,i,j,sum;
printf("input numbers");
scanf("%d",&a);
printf("input 2nd numbers");
scanf("%d",&b);
num1=atoi(a);
num2=atoi(b);
printf("num1 =%d",num1);
printf("num2 =%d",num2);
x=strlen(a);
y=strlen(b);
{
for(i=x;i>=0;i--)
printf("\n%d",a[i]);
}
for(j=y;j>=0;j--)
{
printf("\n%d",b[j]);
}
sum=a[i]+b[j];
printf("sum=%d",sum);
getch();
}