Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I got the following errors. How do I fix them? My code so far is as follows: #include #include const float POUND = 1.31; const

I got the following errors. How do I fix them?

image text in transcribed

My code so far is as follows:

image text in transcribed

#include #include const float POUND = 1.31; const float YEN = 0.0091; const float RUPEE = 0.014; const float EURO = 1.11; char c; int currValue; float exchangeValue; float finValue; int printValue;

struct node{ int value; struct node* next; }; struct node *dollarHead=NULL; struct node *poundHead=NULL; struct node *euroHead=NULL; struct node *yenHead=NULL; struct node *rupeeHead=NULL; struct node *head=NULL; void insert(float value){ struct node** head; if(value==POUND) { head=£Head; } else if(value==YEN) { head=¥Head; } else if(value==RUPEE) { head=&rupeeHead; } else if(value==1) { head=&dollarHead; } else if(value==EURO) { head=&euroHead; } struct node* temp=(node*) malloc(sizeof(struct node)); printf("Enter value"); scanf("%d",&temp->value); temp->next=NULL; if(*head==NULL) { *head=temp; } else { temp->next=*head; *head=temp; } } void print(float value ) { struct node** head; if(value==POUND) { head=£Head; } else if(value==YEN) { head=¥Head; } else if(value==RUPEE) { head=&rupeeHead } else if(value==1) { head=&dollarHead } else if(value==EURO) { head=&euroHead; } struct node* temp=*head; while(temp!=NULL) { printf("%d ",temp->value); temp=temp->next; } printf(" "); } int main(){ while(1) { float rate=currencyExchange(); if(rate==POUND) { insertpound(rate); } else if(rate==YEN) { insert(rate); } else if(rate==RUPEE) { insert(rate); } else if(rate==1) { insert(rate); } else if(rate==EURO) { insert(rate); } printf("Do you want to continue...if yes press Y else N"); char s; scanf("%c",&s); if(s=='Y' || s=='y') continue; else break; } printf("Pound currency "); print(POUND); printf("Yen currency "); print(YEN); printf("Rupee currency "); print(RUPEE); printf("Euro currency "); print(EURO); printf("Dollar currency "); print(1); } float exchangeValue(){ 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; } } } }

stackcurr.c:24:14: error: conflicting types for 'head' struct node *head=NULL; stackcurr.c:1:15: note: previous declaration of 'head' was here struct node** head; stackcurr.c: In function 'insert': stackcurr.c:47:20: error: 'node' undeclared (first use in this function), struct node* temp= (node*) malloc(sizeof (struct node)); stackcurr.c:47:20: note: each undeclared identifier is reported only once for each function it appears stackcurr.c:47:25: error: expected expression before token struct node* temp=(node*) malloc(sizeof(struct node)); stackcurr.c: In function 'print': stackcurr.c:75:1: error: expected ';' before 'j' token stackcurr.c:79:1: error: expected ';' before '' token stackcurr.c: At top level: stackcurr.c:135:7: error: 'exchangeValue' redeclared as different kind of symbol float exchangeValue() { stackcurr.c:11:7: note: previous declaration of 'exchangeValue' was here float exchangeValue; stackcurr.c: In function exchangeValue': stackcurr.c:140:15: error: 'exchangeRate' undeclared (first use in this function) return exchangeRate; stackcurr.c:170:63: error: expected declaration or statement at end of input Write a C program that reads in an arbitrarily long sequence of positive integer currency values in the style of Project 1), and outputs each category of currency in reverse order. Your converter should understand dollars ('S'), Euros (''), British pounds sterling (''), the Japanese Yen (''), and the Indian Rupee ('5'). This should reuse code from your previous project. Your program should ignore any amount of white space between currency values, including tabs, spaces, newlines, etc. See the isspace() function in your text or in the man pages for details. However, your output should place each currency value on a line by itself. When the end of input ("EOF") is reached, the piles should be printed in order of dollars, British pounds sterling, Japanese Yen, Euros, and finally Indian Rupees. To store an arbitrary list of integers, your program will need to request more memory from the operating system when the space it already has runs out. This kind of dynamic allocation is performed using the malloc() function, as detailed in your text and in the man pages. You may assume that we will test your program with at least 100,000,000 integers. Your program should exit gracefully if a malloc() request is denied

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Temple Of Django Database Performance

Authors: Andrew Brookins

1st Edition

1734303700, 978-1734303704

Students also viewed these Databases questions

Question

2. What is the meaning and definition of Banking?

Answered: 1 week ago

Question

3.What are the Importance / Role of Bank in Business?

Answered: 1 week ago