w3resource logo

:

C Programming Exercises

C Exercises: Find the integral quotient and remainder of a division

C Variable Type : Exercise-7 with Solution

Write a C program to integral quotient and remainder of a division.

Sample Solution:

C Code:

#include<stdio.h>
#include<stdlib.h>

int main ()
{
    long int n,d;
	ldiv_t result;
	
	      printf("\n Input numerator : ");
	      scanf("%ld",&n);	
	      printf(" Input denominator : ");
	      scanf("%ld",&d);		      
	result = ldiv (n,d);
	printf (" quotient =  %ld, remainder = %ld.\n\n",result.quot,result.rem);
	return 0;
}

Sample Output:

 Input numerator : 2500                                                                                       
 Input denominator : 235                                                                                      
 quotient =  10, remainder = 150.

C Programming Code Editor:

Improve this sample solution and post your code through Disqus