473,662 Members | 2,581 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

1 New Member
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 8602
Rabbit
12,516 Recognized Expert Moderator MVP
You can't mod a float. Mod is only for integers.
Oct 20 '11 #2
whodgson
542 Contributor
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
9683
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 script I get the following interpreter error.
2
4403
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> class Creature { public: unint ReturnSpellPoints() {return crSpellPoints;}
3
3158
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' : 'white'} ): any idea what i'm doing wrong here?
6
13565
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 cStepCurveEvaluator.cpp(14) : error C2296: '.*' : illegal, left operand
2
2119
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 over come this compiler error .
4
11829
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
6623
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 } heres the whole code
15
3601
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. There is also several tests in place to check the data being read into the program to return an error if there are characters that can't be used for a file or folder. There is an option to clean the data being read in which it will read a line of...
2
7150
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 SecondProd,ForthProd;
1
12850
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 POUNDS_PER_KILOGRAM = 2.2;
0
8344
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8764
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7367
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5654
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4347
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1993
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1752
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.