-1

i started programming in c++. I wrote one line code in c++ and i got an error which i cant solve.

In order to fix this problem i searched some internet pages but i cant find the solution to this problem. Here is the Code:

#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;

int main()
{
    cout <<remainder(10 % 3.25) << endl;`
}

I cant execute this code. The failurelog says that the function remainder and fmod cant be found. I also tried it out to include the math.h lib.

Can someone help me to fix my problem?

Many thanks Pat

Patrick
  • 1
  • 2
  • *In order to fix this problem i searched some internet pages* -- The [documentation](https://en.cppreference.com/w/cpp/numeric/math/remainder) shows remainder as taking two arguments. The `%` operator doesn't make sense there. – PaulMcKenzie Apr 01 '20 at 12:49

1 Answers1

1

It's

cout <<remainder(10 , 3.25) << endl;

By remainder(10 , 3.25) you are passing 2 arguments to the function remainder.

10 % 3.25 is not valid because the second argument for the operator % is double.

See https://en.cppreference.com/w/cpp/numeric/math/remainder

And there is no need for #include <stdio.h>

See Why is "using namespace std;" considered bad practice?

asmmo
  • 6,922
  • 1
  • 11
  • 25