C Program to find Remainder or Modulus of two numbers

Share:

Q. – Write a C program to find the Remainder of given two numbers.

Ans:- Two numbers, says a and b, are given (input) and the result remainder = a%b of two numbers are to be calculated.



/* Arithmetic Operators Remainder */
#include <stdio.h>
main()
{
    int a, b, remainder;
    scanf("%d %d", &a, &b);
    remainder = a%b;
    printf("%d", remainder);
    return 0;

}

User Friendly Program

/* Arithmetic Operators Remainder – User friendly program */
#include<stdio.h>
main()
{
    int a, b, remainder;
    printf("\n Enter Value to A: ");
    scanf("%d", &a);
    printf("\n Enter Value to B: ");
    scanf("%d", &b);
    remainder = a%b;
    printf("\n Remainder = %d", remainder);
    return 0;

}

No comments