Math Remquo Function - C++ Programming Tutorial
C++ Course / Math Functions / Math Remquo Function

Math Remquo Function

BLUF: Mastering Math Remquo Function is a critical step in becoming a proficient C++ developer. This lesson provides a deep dive into the syntax, performance considerations, and real-world applications of this concept.
Key Performance Insight: Math Remquo Function

C++ is renowned for its efficiency. Learn how Math Remquo Function enables low-level control and high-performance computing in the tutorial below.

C++ Math remquo

The function calculates the floating-point modulus of the numerator divided by the denominator (rounded to the nearest integer) and simultaneously saves the quotient internally to the pointer provided as a parameter to the function.

Syntax

Suppose 'n' represents the numerator, 'd' represents the denominator, and 'p' represents the pointer. The syntax for this scenario would be as follows:

Example

return_type remquo(data_type n, data_type d, int* p);

Note: The return_type can be float, double or long double.

Parameter

n : The value of numerator.

d : The value of denominator.

The pointer refers to an object where the result of the division operation is internally stored.

Return value

It returns the floating point remainder n/d.

Example 1

Let's explore a basic scenario where the parameters are of identical data type.

Example

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
   float x=7.6;
   float y=5.4;
   int* p;
   std::cout << "Value of remainder is :" << remquo(x,y,p)<<'\n';
   cout<<"Value of quotient is :"<<*p;
   return 0;
}

Output:

Output

Value of remainder is :2.2
Value of quotient is :1

Example 2

Let's explore a basic scenario where the parameters are of varying data types.

Example

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
   int x=2;
  float y=1.1;
  int* q;
  std::cout << "Value of remainder is :" <<remquo(x,y,q)<<'\n';
  cout<<"Value of quotient is :"<<*q;
  return 0;
}

Output:

Output

Value of remainder is :0.2
Value of quotient is :2

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience