473,425 Members | 1,763 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,425 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 9442
dev7060
638 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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...
0
Oralloy
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,...
0
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

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.