Print Remainder when Divided by 5

The program must accept a number and print its remainder when it divided by 5.

Example Input/Output 1:
Input:
12

Output:
2

Example Input/Output 2:
Input:
10

Output:
0

Python

N = int(input())
print(N%5) 

Java

import java.util.*;
public class Hello {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        System.out.print(N % 5);
    }
}

C

#include <stdlib.h>
#include  <stdio.h>
int main()
{
    int N;
    scanf("%d",&N);
    printf("%d",N%5);
}

C++

#include <iostream>
using namespace std;
int main()
{
    int N;
    cin >> N;
    cout << N%5;
    return 0;
}

Leave a Reply

Your email address will not be published. Required fields are marked *

More posts. You may also be interested in.