473,287 Members | 1,643 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,287 software developers and data experts.

[Error] invalid operands of types 'double' and 'double' to binary 'operator%'

11 Byte
Hey, can you guys tell me how to get this correct?It says "[Error] invalid operands of types 'double' and 'double' to binary 'operator%' "But I don't know what the error is!Under this sentence is my code:
Expand|Select|Wrap|Line Numbers
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. double n,x,y,a;
  4. int main(){
  5.     cin>>n>>x>>y;
  6.     a=ceil(y/x);
  7.     if(y%x==0)cout<<n-y/x<<endl;
  8.     else cout<<n-a<<endl;
  9.     return 0;
  10. }
(From the angry writer:Ahhh......This DUMBDUDE code......)
May 12 '22 #1
1 9292
dev7060
626 Expert 512MB
[Error] invalid operands of types 'double' and 'double' to binary 'operator%'
% works with integral operands.

Use fmod https://www.cplusplus.com/reference/cmath/fmod/

Also, decimal comparisons may not be accurate.
May 13 '22 #2

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

Similar topics

4
by: muthu | last post by:
In the following code it gives the error "error: invalid operands to binary &" Why it is happening #include <signal.h> #include <errno.h> #define SIGBAD(signo) ((signo) <= 0 || (signo) >=...
2
by: xelloss | last post by:
#include<cstdlib> #include<iostream> #include<iomanip> #include<vector> #include<fstream> using namespace std; double sum(vector<double> x) { double total = 0.0;
2
by: clintonb | last post by:
Victor said: The double value that I'm trying to convert to GCSMoney (which is implemented as cents) was produced by multiplying a dollar amount by an interest rate to get interest. double...
2
by: Genro | last post by:
#include<stdio.h> #include<TX/graphics.h> #include<time.h> // I need help! struct Krug{ double _x; double _y; double _skox; double _skoy; double...
2
by: Tyler Palmer | last post by:
I am having a problem with my program. I cant figure out a solution for the compiler error im getting. In function `double endingConversion(double)': invalid operands of types `double...
2
by: SunDevil1171 | last post by:
I making a simple single number scrambler/encryptor and as I tried to build the console application the following error occurred: error: invalid operands of types 'void' and 'int' to binary...
3
by: jktruimp1 | last post by:
I am trying to reduce fractions. If I replace double by int,there is no error,and it will run answers. But the wrong one..... I don't know if I use the reducing fractions' rule wrongly. Can...
3
by: AndreyKiber | last post by:
It seems to me that there is an error in type n, but whatever type I put it still appears, just change to int n, float n, double n, but it still does not work. #include <iostream> #include <cmath>...
2
SwissProgrammer
by: SwissProgrammer | last post by:
A question from help I was getting on page https://bytes.com/topic/c/answers/974514-what-minimum-requirements-all-17-planes-unicode-c#post3829190 There is a lot on that page, so I separated...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.