Modulus of Two Numbers || Functions in C++|| Arithmetic Operation || || Functions|| Modulus ||C++
In this, we are going to see Functions, the program is based on function which Calculates, Profit or Loss.

The code given below can be used for TURBO C++ Compiler:-

#include <iostream.h>
#include<conio.h>

int dividend, divisor, remainder_of_two;

void get_numbers()
{
    cout << "\nEnter the Divdend and Divisor to check remainder\n";
    cout << "Dividend :  ";
    cin >> dividend;
    cout << "Divisor :   ";
    cin >> divisor;
}

void calculate_remainder()
{
    remainder_of_two = dividend % divisor;
    cout << "The remainder for " << dividend << " / " << divisor << " is " << remainder_of_two;
}

void main()
{
    clrscr();
    get_numbers();
    calculate_remainder();

    getch();
}
	
    
The code given below can be used for g++/gcc Compiler:-

#include <iostream>
using namespace std;

int dividend, divisor, remainder_of_two;

void get_numbers()
{
    cout << "\nEnter the Divdend and Divisor to check remainder\n";
    cout << "Dividend :  ";
    cin >> dividend;
    cout << "Divisor :   ";
    cin >> divisor;
}

void calculate_remainder()
{
    remainder_of_two = dividend % divisor;
    cout << "The remainder for " << dividend << " / " << divisor << " is " << remainder_of_two;
}

int main()
{
    get_numbers();
    calculate_remainder();

    return 0;
}
	
    
#ENJOY CODING
 

Post a Comment

FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP

Previous Post Next Post