i got this error(error C2297: '%' : illegal, right operand has type 'double') in this programmig,
who can help me? -
-
#include<stdio.h>
-
int main(void)
-
{
-
printf("Amount of sale ($):\t");
-
float a;
-
scanf("%f", &a);
-
-
printf("Cash tendered ($):\t");
-
float b;
-
scanf("%f", &b);
-
-
int twenties,tens,fives,ones;
-
-
printf("Change:\n");
-
float c;
-
c = b - a;
-
-
-
-
printf("twenties:\t");
-
twenties=c/20;
-
printf("%d",twenties);
-
-
int m,l,o,q,d,n,p;
-
-
m=(c%20);
-
printf("tens:\t");
-
tens=m/10;
-
printf("%d",tens);
-
-
l=(m%10);
-
printf("fives:\t");
-
fives=l/5;
-
printf("%d",fives);
-
-
o=(l%5);
-
printf("ones:\t");
-
ones=o/1;
-
printf("%d",ones);
-
-
int quarters,dimes,nickels,pennies;
-
-
q=(o%1);
-
printf("quarters:\t");
-
quarters=q/0.25;
-
printf("%d",quarters);
-
-
d=(q%0.25);
-
printf("dimes:\t");
-
dimes=d/0.10;
-
printf("%d",dimes);
-
-
n=(d%0.10);
-
printf("nickels:\t");
-
nickels=n/0.05;
-
printf("%d",nickels);
-
-
p=(n%0.05);
-
printf("pennies:\t");
-
printf("%d",p);
-
-
-
return 0;
-
}
-
2 8602 Rabbit 12,516
Recognized Expert Moderator MVP
You can't mod a float. Mod is only for integers.
Yes...but you can of course 'modf'
Sign in to post your reply or Sign up for a free account.
Similar topics |
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.
|
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;}
|
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?
|
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
|
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 .
| |
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
{
|
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
|
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...
|
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;
|
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;
|
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,...
| |
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...
|
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...
|
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...
|
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();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| | |