Computer Scientists are Pretty Pessimistic

Friday 4 September 2015

WAP to find out the quotient and remainder of two numbers. ( Without using modulus ( % ) operator)

#include <stdio.h>
int main ()
{
    int x,y,q,r;
    printf("Enter Divisor: ");
    scanf("%d",&x);
    printf("Enter Dividend: ");
    scanf("%d",&y);

    q=y/x;
    r=y-(x*q);

    printf("Quotient is %d\n",q);
    printf("Remainder is %d\n",r);
    return 0;
}

No comments:

Post a Comment