stack_example - ADDITION OF TWO NUMBERS WITH MAX SIZE UP TO...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
ADDITION OF TWO NUMBERS WITH MAX SIZE UP TO 40 DIGITS 289765 and 897 Read the numbers and stack them (upside down) stack1 stack2 s 5 7 s 6 9 s 7 8 s 9 s 8 s 2 Add corresponding elements and take care of carry – 2354 and 897 ?? typedef struct { int *items; int top; const int max;
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
typedef enum {false, true} bool; bool push(stack *a, int item); int pop(stack *a); void readNumber(stack *location, bool *isnegative); void printNumber(stack *number, bool isnegative); int compareNumbers(const int first[], int first_top, const int scnd[], int scnd_top); void addition(stack *first_number, bool first_negative, stack *scnd_number, bool scnd_negative, stack *answer); void add(stack *first, stack *scnd, stack *answer); int main(void) { bool first_negative, scnd_negative; char choice; stack first_number, scnd_number, answer; int a[82], f[40], s[40]; //These are to be used to allocate the proper //amount of space for each stack first_number.max = scnd_number.max = 40; answer.max = 82; first_number.top = scnd_number.top = answer.top = -1;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

stack_example - ADDITION OF TWO NUMBERS WITH MAX SIZE UP TO...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online