473,396 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

error C2297: '%' : illegal, right operand has type 'double'

i got this error(error C2297: '%' : illegal, right operand has type 'double') in this programmig,
who can help me?

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include<stdio.h>
  3. int main(void)
  4. {
  5.     printf("Amount of sale ($):\t");
  6. float a;
  7. scanf("%f", &a);
  8.  
  9. printf("Cash tendered ($):\t");
  10. float b;
  11. scanf("%f", &b);
  12.  
  13. int twenties,tens,fives,ones;
  14.  
  15. printf("Change:\n");
  16. float c;
  17. c = b - a;
  18.  
  19.  
  20.  
  21. printf("twenties:\t");
  22. twenties=c/20;
  23. printf("%d",twenties);
  24.  
  25. int m,l,o,q,d,n,p;
  26.  
  27. m=(c%20);
  28. printf("tens:\t");
  29. tens=m/10;
  30. printf("%d",tens);
  31.  
  32. l=(m%10);
  33. printf("fives:\t");
  34. fives=l/5;
  35. printf("%d",fives);
  36.  
  37. o=(l%5);
  38. printf("ones:\t");
  39. ones=o/1;
  40. printf("%d",ones);
  41.  
  42. int quarters,dimes,nickels,pennies;
  43.  
  44. q=(o%1);
  45. printf("quarters:\t");
  46. quarters=q/0.25;
  47. printf("%d",quarters);
  48.  
  49. d=(q%0.25);
  50. printf("dimes:\t");
  51. dimes=d/0.10;
  52. printf("%d",dimes);
  53.  
  54. n=(d%0.10);
  55. printf("nickels:\t");
  56. nickels=n/0.05;
  57. printf("%d",nickels);
  58.  
  59. p=(n%0.05);
  60. printf("pennies:\t");
  61. printf("%d",p);
  62.  
  63.  
  64. return 0;
  65. }
  66.  
Oct 20 '11 #1
2 8570
Rabbit
12,516 Expert Mod 8TB
You can't mod a float. Mod is only for integers.
Oct 20 '11 #2
whodgson
542 512MB
Yes...but you can of course 'modf'
Oct 21 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Rakesh | last post by:
In my Python code fragment, I want to write a code fragment such that the minimum element of a tuple is subtracted from all the elements of a given tuple. When I execute the following python...
2
by: Tim Mierzejewski | last post by:
You guys were so great with answering my first question that I've decided to ask you yet again! Again, only the relevant code is included. typedef unsigned int unint; #include <iostream> ...
3
by: yaffa | last post by:
hey folks i get this error: Python interpreter error: unsupported operand type(s) for |: when i run this line of code: for incident in bs('tr', {'bgcolor' : '#eeeeee'} | {'bgcolor' :...
6
by: BlueTrin | last post by:
Hello I was adapting a C version of SolvOpt in C++ to use it within a virtual class. However I am stuck with the overriding of evaluation and gradiant functions. cStepCurveEvaluator.cpp...
2
by: duraisridhar | last post by:
Hi all, While I try to find the modulus on double data , Compiler throws following error "Test.cpp(180): error C2296: '%' : illegal, left operand has type 'double' " Any work around to...
4
momotaro
by: momotaro | last post by:
the problem is in the function "Swap" This is the error message that i get: Error 3 error C2088: '*' : illegal for struct and this is my prog: #include <stdio.h> typedef struct {
2
by: dobbouk | last post by:
I'm getting these 2 errors and haven't got a clue whats causing them please java 43: illegal start of type for (i=0;i< Number_of_squares; i++) java 215 identifier expected } ...
15
by: Fuzz13 | last post by:
I'm writing a program that a user loads a file (txt or csv) in which it reads newlines and commas as new object delimiters. Each new object is put into an array creating a new array object each time....
2
by: Mark05 | last post by:
#include<conio.h> #include<iostream> using namespace std; int main() { double ManfCode,ProdCode; int Checkdigit, SecondManf, FourthManf; int FirstProd,ThirdProd,FifthProd; int...
1
by: Terry Archer | last post by:
error C2296: '%' : illegal,left operand has type 'double' #include <iostream> #include <fstream> #include <iomanip> using namespace std; const int OUNCES_PER_POUND = 16; const double...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.