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 8570
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...
|
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>
...
|
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' :...
|
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...
|
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...
|
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
}
...
|
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....
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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,...
| | |