Monday 2 February 2015

div() Function in C++

Structure of the Problem Requirements 

This Program 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 it Please
asad

About Author!

Asad Niazi is Software Engineer , Programmer, Web Developers and a young mentor of Tech Solutions Desk and Blogging Solutions . Asad Love to writes about Technology, Programming, Blogging and make money online.

0 comments:

Post a Comment