472,372 Members | 1,871 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,372 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 7798
dev7060
625 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
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

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.