Answers for "how to do modulo in c"

C
3

c modulo

x % y
Posted by: Guest on March-20-2021
0

how to modulo in c without %

#include<stdio.h>

int main()
{
    //1
    int no,divisor,remainder;
    
    //2
    printf("Enter the number : ");
    scanf("%d",&no);
    
    //3
    printf("Enter the divisor : ");
    scanf("%d",&divisor);
    
    //4
    while(no >= divisor){
        no = no - divisor;
    }
    
    //5
    remainder = no;
    
    //6
    printf("The remainder is %d ",remainder);
    
    return 0;
}
Posted by: Guest on May-29-2021

Code answers related to "C"

Browse Popular Code Answers by Language