C Program to Check Number is divisible by 6 or Not and the print remainder

Write a program to accept a number and check if it is divisible by 6 or Not and print the remainder.

Examples:

Input: 7
Output: 1

Input: 36
Output: Divisible by 6

Input: 45
Output: 3

Code:

#include<stdio.h>

int main(){
    int n;

    scanf("%d",&n);

    if(n%6==0) printf("Divisible by 6");
    else printf("%d",n%6);
}
Code language: C/AL (cal)

Leave a Comment