hi friends em new here my first day first post
friends any one of you plz tell me long hand int calculations project its urgent coz i have to present it 26th of this month.:confused:
Printable View
hi friends em new here my first day first post
friends any one of you plz tell me long hand int calculations project its urgent coz i have to present it 26th of this month.:confused:
wtf..>?!?!
Please be more specific!
So what were you planning to do for the next two weeks?
I suppose we should be thankful, some people show up here with 13 hours to go to the deadline (and they haven't started yet).
You've got plenty of time, make an attempt for the next day or two then post something.
uuuuuuuuuuuuufffffffffff plz any one of u help me i have30 assignments of c as well n a project of communication skills and a n assigment of globalization and and and.......... and examz starts from 26th of this month i m too much bz but it doesnot matter how much i bz actually i dont how to solve it
So what's the problem? Specifically . . . ?
Show us some code and we'll help you solve the problems. Just paste them within [code][/code] tags
Code:#define MAXDIGITS 100;
main()
type struct{
char digit[MAXDIGITS]
int signbit,
int last digit,
}big num;
digit m1,m2,m3;
***************************************
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)
}
there are too much errors in this code actually this was given by my teacher and i copy it from white board
> #define MAXDIGITS 100;
Drop the ; at the end of this line
> main()
You should be specific about what the function returns.
main for instance always returns int. Your other function should probably return void
> char digit[MAXDIGITS]
Each member of your struct should finish with a ;
Like
char digit[MAXDIGITS];
> int last digit,
C doesn't allow spaces in variable names. So
int lastdigit;
int lastDigit;
int last_digit;
pick a style you like.
> n->signbit='PLUS'
Maybe just
n->signbit='+';
Again, don't forget those ;
You sure your teacher wrote that code?
Here's the function fixed:
There were tones of mistakes! From misnaming variables, missing ;'s, spaces in variables not to mention the indenting!Code:typedef struct
{
char digit[100];
int signbit;
int last_digit;
} big_num;
void ch_to_bignum( char*s,big_num*n )
{
int i;
if(s[0]!='-')
{
n->signbit='+';
i=0;
}
else
{
i=1;
n->signbit='-';
}
strcpy(n->digit,&s[i]);
n->last_digit=strlen(n->digit);
}
Use it like this:
Code:int main( void )
{
big_num m1;
char *test_ch = "242";
ch_to_bignum( test_ch, &m1 );
cout<< m1.digit << '\n'
<< m1.last_digit << '\n'
<< m1.signbit << '\n';
return 0;
}
hey this is not the actuall code my sir gives my this i have to solve long long integres calculation e.d 10000000000000000000000000000000000000000000000000 000000000000000+1000000000000000000000000000000000 000000000000000000000000000000000000000000000 like this and subtraction and division as well
thx but in last line i have to print PLUS not +Quote:
Originally Posted by Salem
thx buddy but this will not only solve my prob me have to solve long long int calculationsQuote:
Originally Posted by twomers
Yes, you are well on your way to solving that. You cannot expect generous handouts without doing your part. If you do not do your part, you can expect handouts that generously fail you in subtle ways devised by us.Quote:
thx buddy but this will not only solve my prob me have to solve long long int calculations
ya my teacher wrote that code but he was just giving us hints
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();
}