- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

Here we will see the functionality of remainder() method of C++. The remainder() function is used to compute the floating point remainder of numerator/denominator.

So the remainder(x, y) will be like below.

remainder(x, y) = x – rquote * y

The rquote is the value of x/y. This is rounded towards the nearest integral value. This function takes two arguments of type double, float, long double, and returns the remainder of the same type, that was given as argument. The first argument is numerator, and the second argument is the denominator.

#include <iostream> #include <cmath> using namespace std; main() { double x = 14.5, y = 4.1; double res = remainder(x, y); cout << "Remainder of " << x << "/" << y << " is: " << res << endl; x = -34.50; y = 4.0; res = remainder(x, y); cout << "Remainder of " << x << "/" << y << " is: " << res << endl; x = 65.23; y = 0; res = remainder(x, y); cout << "Remainder of " << x << "/" << y << " is: " << res << endl; }

Remainder of 14.5/4.1 is: -1.9 Remainder of -34.5/4 is: 1.5 Remainder of 65.23/0 is: nan

- Related Questions & Answers
- remainder() in C++ program
- Modulo / Remainder in Arduino
- C++ Program to Find Quotient and Remainder
- C Program to Compute Quotient and Remainder?
- C++ Program for quotient and remainder of big number
- Program to find remainder without using modulo or % operator in C++
- C# program to accept two integers and return the remainder
- Program to find Quotient and Remainder in Java
- Java program to compute Remainder and Quotient
- Program to find remainder when large number is divided by 11 in C++
- Program to find remainder when large number is divided by r in C++
- Find N % (Remainder with 4) for a large value of N in C++
- How to perform integer division and get the remainder in JavaScript?
- Python Program to Read Two Numbers and Print Their Quotient and Remainder
- Golang Program to Read Two Numbers and Print their Quotient and Remainder

Advertisements