Question: Hi, I need to make a program in C that reads the type of currency and organizes them into stacks based on currency which can
Hi, I need to make a program in C that reads the type of currency and organizes them into stacks based on currency which can be read back. This is what I have so far, can I get help finishing it?
#include
struct node { int value; struct node *next; };
struct node *dollarHead; struct node *poundHead; struct node *euroHead; struct node *yenHead; struct node *rupeeHead; struct node *head; int main(){ dollarHead = malloc(sizeof(struct node)); poundHead = malloc(sizeof(struct node)); euroHead = malloc(sizeof(struct node)); yenHead = malloc(sizeof(struct node)); rupeeHead = malloc(sizeof(struct node)); head = malloc(sizeof(struct node));
if (head == NULL){ printf("UHHH ERROR"); } else { printf("%x ", head); head->value = 36; head->next = NULL; printf("h value: %x ", head->value); printf("h next: %x ", head->next);
float currencyExchange() { float exchangeRate = 1; c = getchar(); if ( c == '$') { printf("$"); return exchangeRate; } else if (c =='\xC2') { c = getchar(); if (c == '\xA3') { printf(""); exchangeRate = POUND; return exchangeRate;
} else if (c == '\xA5') { printf(""); exchangeRate= YEN; //printf("the exchange rate is %f",exchangeRate); return exchangeRate; } else{ c = getchar(); c = getchar(); if(c== '\xB9') { printf(""); exchangeRate = RUPEE; return exchangeRate; } else if (c == '\xAC') { printf(""); exchangeRate = EURO; return exchangeRate; } else } } } //
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
