Quick links
Latest articles
Internship
Members
New...
Algorithms
Discrete Mathematics
Big data
Languages
C
C++
C++ STL
Java
Data Structure
C#.Net
Android
Kotlin
SQL
Web
PHP
Python
JavaScript
CSS
Ajax
Node.js
Web prog.
Programs
C
C++
DS
Java
C#
Python
Aptitude
C
C++
Java
DBMS
Interview
C
Embedded C
Java
SEO
HR
CS Subjects
CS Basics
O.S.
Networks
DBMS
Embedded Systems
Cloud Computing
Machine learning
CS Organizations
Linux
DOS
More...
Articles
Puzzles
News/Updates

Home » C programs » C MISC. programs

C program to find remainder of two numbers without using modulus (%) operator



In this C program, we will learn how can we find the remainder of two integer numbers without using modulus (%) operator?
Submitted by IncludeHelp, on April 26, 2018

Given two integer numbers and we have to find the remainder without using modulus operator (%) in C.

Here, we will read two integers numbers and find their remainder. To get the remainder we will not use the modulus (%) operator.

Formulas to get the remainder,

1) Using modulus (%) operator

    rem = a%b;

2) Without using modulus (%) operator

    rem = a-(a/b)*b;

Here, a and b are the input numbers.

C program to find the remainder of two numbers without using modulus (%) operator



/*
    * Program to get remaindar without using % operator.
*/
 
#include <stdio.h>
int main()
{
    int a,b,rem;
    printf("Enter first number :");
    scanf("%d",&a);
    printf("Enter second number :");
    scanf("%d",&b);
 
    rem=a-(a/b)*b;
 
    printf("Remainder is = %d\n",rem);
    return 0;
}

Output

    Enter first number :16
    Enter second number :7
    Remainder is = 2    





Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Featured post:
Introduction to Linux (Its modes, Safety, Most popular Applications)
Linux Best Distribution Software (Distros) of 2018

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com (2015-2018), Some rights reserved.