Div() Function in C++

This Program will find the Quotient and remainder of any number we used div() function. The div() function exist in stdlib.h library. The complete signature of the function is div_t r (int a ,int b) where a is numerator and b is denominator.

Source Code 

#include <stdlib.h>
#include<iostream>
using namespace std;
int main ()
{
div_t r;
int number1,number2;
cout<<" \t \t \t LEP Tutorials \n \n  ";
cout<<"Enter Number : ";
cin>>number1;
cout<<endl;
cout<<"  Enter Number : ";
cin>>number2;
r=div(number1,number2);
cout<<endl;
cout<<" The Quotient is :"<<(r.quot);
cout<<endl<<endl;
cout<<" The Remainder is :"<<(r.rem);
cout<<endl<<endl;
}

Output of the Program

div() Function in C++



Share on Google Plus

About Asad

Asad Niazi is Software Engineer , Programmer, Web Developer and a young mentor of BloggersTown and PProgramming. Asad Love to writes about Technology, Programming, Blogging and make money online.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment