GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 07-Nov-2009, 22:33
cheifjoe87 cheifjoe87 is offline
New Member
 
Join Date: Nov 2009
Posts: 5
cheifjoe87 is on a distinguished road

Opperand variable type errors.


Ok the source code for the program is listed below,along with the program outline.

And here are the problems with the program that im experiencing.

Wedit output window build: Fri Nov 06 16:57:55 2009
e:\cop2000\project6\#6.c:
Error #6.c: 47 operands of / have illegal types 'pointer to int' and 'double'
Error #6.c: 47 operands of = have illegal types 'pointer to int' and 'int'
Error #6.c: 48 operands of / have illegal types 'pointer to int' and 'double'
Error #6.c: 48 operands of = have illegal types 'pointer to int' and 'int'
Error #6.c: 49 operands of / have illegal types 'pointer to int' and 'double'
Error #6.c: 49 operands of = have illegal types 'pointer to int' and 'int'
Error #6.c: 50 operands of / have illegal types 'pointer to int' and 'double'
Error #6.c: 50 operands of = have illegal types 'pointer to int' and 'int'
Error #6.c: 54 operands of / have illegal types 'pointer to int' and 'double'
Error #6.c: 54 operands of = have illegal types 'pointer to int' and 'int'
Error #6.c: 55 operands of / have illegal types 'pointer to int' and 'double'
Error #6.c: 55 operands of = have illegal types 'pointer to int' and 'int'
Error #6.c: 56 operands of / have illegal types 'pointer to int' and 'double'
Error #6.c: 56 operands of = have illegal types 'pointer to int' and 'int'
Error #6.c: 57 operands of / have illegal types 'pointer to int' and 'double'
Error #6.c: 57 operands of = have illegal types 'pointer to int' and 'int'
Compilation + link time:0.6 sec, Return code: 1


/*Problem: write a program to dispense change.The user enters the ammount paid and the
ammount due.The program determines how many dollars,quarters,dimes,nickles,pennies to give as change.
write a function with four parameters that determines the quantity of each kind of coin.Also the
program needs a for loop so the user can stop when the wish.

CPP / C++ / C Code:
#include <stdio.h>
#define Quarters_1 0.25
#define Dimes_1 0.10
#define Nickles_1 0.5
#define Pennies_1 0.1
#define Quarters_2 0.25
#define Dimes_2 0.10
#define Nickles_2 0.5
#define Pennies_2 0.1
void Ammount_P(int *quarters_1,int *dimes_1,int *nickles_1,int *pennies_1,int *ammount_paid);
void Ammount_D(int *quarters_2,int *dimes_2,int *nickles_2,int *pennies_2,int *ammount_due);
int main(void)
{
int quarters_1,dimes_1,nickles_1,pennies_1,quarters_2,dimes_2,nickles_2,pennies_2,
ammount_paid,ammount_due,input = -1,end = 0;

while ( input != 0 )
{
printf("Enter integer zero to exit program or integer 1 to continue program > ");
scanf("%d",&input);
end = end + input;
}
while (input == 1)
{
printf("Enter the ammount paid.");
scanf("%d",&ammount_paid);
printf("\nEnter the ammount due.");
scanf("%d",&ammount_due);

Ammount_P(&quarters_1,&dimes_1,&nickles_1,&pennies_1,&ammount_paid);
Ammount_D(&quarters_2,&dimes_2,&nickles_2,&pennies_2,&ammount_due);

printf("The ammount paid is QUARTERS %d,DIMES %d,NICKLES %d,PENNIES %d",
quarters_1,dimes_1,nickles_1,pennies_1);
printf("The ammount due is QUARTERS %d,DIMES %d,NICKLES %d,PENNIES %d",
quarters_2,dimes_2,nickles_2,pennies_2);
}
return(0);
}
void Ammount_P(int *quarters_1,int *dimes_1,int *nickles_1,int *pennies_1,int *ammount_paid)
{
quarters_1 = ammount_paid / Quarters_1;
dimes_1 = ammount_paid / Dimes_1;
nickles_1 = ammount_paid / Nickles_1;
pennies_1 = ammount_paid / Pennies_1;
}
void Ammount_D(int *quarters_2,int *dimes_2,int *nickles_2,int *pennies_2,int *ammount_due)
{
quarters_2 = ammount_due / Quarters_2;
dimes_2 = ammount_due / Dimes_2;
nickles_2 = ammount_due / Nickles_2;
pennies_2 = ammount_due / Pennies_2;
}
Last edited by LuciWiz : 08-Nov-2009 at 09:53. Reason: Please insert your C code between [cpp] & [/cpp] tags
  #2  
Old 08-Nov-2009, 08:11
fakepoo fakepoo is offline
Regular Member
 
Join Date: Oct 2007
Posts: 761
fakepoo is a jewel in the roughfakepoo is a jewel in the roughfakepoo is a jewel in the rough

Re: Opperand variable type errors.


CPP / C++ / C Code:
Ammount_P(&quarters_1,&dimes_1,&nickles_1,&pennies _1,&ammount_paid);
Here, there is a space between "&pennies" and "_1". Could this be causing your error?
  #3  
Old 08-Nov-2009, 08:13
Howard_L Howard_L is offline
Regular Member
 
Join Date: Apr 2007
Location: Maryland/PA, USA
Posts: 846
Howard_L is a jewel in the roughHoward_L is a jewel in the roughHoward_L is a jewel in the rough

Re: Opperand variable type errors.


Quote:
The user enters the amount paid and the amount due?

Where is this place , I'd like to shop there. I got a big-A change sack to bring too!

Is that the way the assignment reads?

Why didn't you take the time to learn to use code tags for the code in your post?
PLEASE READ THE GUIDELINES to learn how to post rightly.

Well first look carefully and you will see a problem with two of these:
CPP / C++ / C Code:
#define Dimes_1    0.10
#define Nickles_1  0.5
#define Pennies_1  0.1

When I compile your code ("/*Problem: ..." as line 1) I get:
Code:
forums> gcc -Wall -W -pedantic 091108_coins-1.c -o 091108_coins-1 091108_coins-1.c:35: error: ‘pennies’ undeclared (first use in this function) 091108_coins-1.c:35: error: expected ‘)’ before ‘_1’ 091108_coins-1.c:35: error: too few arguments to function ‘Ammount_P’ 091108_coins-1.c:36: error: expected ‘)’ before ‘_2’ 091108_coins-1.c:36: error: too few arguments to function ‘Ammount_D’ 091108_coins-1.c: In function ‘Ammount_P’: 091108_coins-1.c:47 (thru 50) : error: invalid operands to binary / 091108_coins-1.c:54 (thru 57) : error: invalid operands to binary /
So start with a look at line 35 and 36:
CPP / C++ / C Code:
void Ammount_P(int *quarters_1,int *dimes_1,int *nickles_1,int *pennies_1,int *ammount_paid)
{
    Ammount_P(&quarters_1,&dimes_1,&nickles_1,&pennies _1,&ammount_paid); /*line 35*/
Ammount_D(&quarters_2,&dimes_2,&nickles_2,&pennies _2,&ammount_due);
Same as fakepoo said... do you see the typo in each line?
Now on to 47, 48, 49 and 50:
CPP / C++ / C Code:
  quarters_1 = ammount_paid / Quarters_1;
  dimes_1 = ammount_paid / Dimes_1;
  nickles_1 = ammount_paid / Nickles_1;
  pennies_1 = ammount_paid / Pennies_1;
My error says: "error: invalid operands to binary /"
Yours is even more descriptive: "operands of / have illegal types 'pointer to int' and 'double'"
If you look at the function parameters you will see they are all pointers.
What you have tries to divide a pointer by a value and store that as a pointer. That get's a big "NO WAY DUDE!" from the compiler.
What you need to do instead is use the "*" operator to "dereference" each pointer (use the value stored at that address) like this:
CPP / C++ / C Code:
  *quarters_1 = *ammount_paid / Quarters_1;
You have the same problem for the errors on lines 54 , 55 , 56 and 57. ( but you knew that)
BTW, "ammount" is spelt "amount".
Last edited by Howard_L : 08-Nov-2009 at 09:15.
 
 

Recent GIDBlogNot selected for officer school by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
run script command on ns2.26 newbie06 Computer Software Forum - Linux 66 16-Jan-2010 10:53
Hard drive/CPU Diagnoses Issues binarybug Computer Hardware Forum 1 22-Jan-2007 19:23
template <class Data> problem, more than one data type qboy C++ Forum 1 13-Oct-2006 16:08
syntax errors in document coder MS Visual C++ / MFC Forum 0 11-Mar-2006 04:12
Simple question about while loop Lej C++ Forum 6 07-Aug-2005 13:57

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 08:15.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.