➗ Day 8 – Checking Divisibility of Two Numbers in C

 

➗ Day 8 – Checking Divisibility of Two Numbers in C

Hello readers,

I am Mayur Gund, a first-year Computer Science & Engineering student at Sanjivani College of Engineering. Through Mayur’s Tech Journey, I share my daily coding learnings and reflections as I strengthen my programming foundation.


📝 Today’s Program

On Day 8, I wrote a program in C to check whether one number is completely divisible by another. This is done using the modulus operator (%).


🖥️ C Code Snippet

#include <stdio.h>

int main()

{

  /*

  Program : To check divisibility of two numbers

  Author  : Mayur B Gund

  Date    : 12 Sep 2025

  */

  

  int a, b;

  

  printf("Enter the Dividend\n\n");

  scanf("%d", &a);

  printf("The dividend is %d\n\n", a);


  printf("Enter the Divisor\n\n");

  scanf("%d", &b);

  printf("The divisor is %d\n\n", b);


  int c = a % b;


  if (c == 0) {

      printf("%d is completely divisible by %d", a, b);

  }

  else {

      printf("%d is not completely divisible by %d", a, b);

  }


  return 0;

}

📌 Output Example


Enter the Dividend
20
The dividend is 20

Enter the Divisor
4
The divisor is 4

20 is completely divisible by 4


Enter the Dividend
22
The dividend is 22

Enter the Divisor
5
The divisor is 5

22 is not completely divisible by 5



⚙️ Key Learnings Today

  • Using the modulus operator % to check divisibility.

  • Asking for user inputs and displaying them clearly.

  • Applying if–else logic to interpret results.

  • Importance of adding comments for program readability.



💡 Reflection

This program felt like a natural extension of yesterday’s logic exercises. It reminded me how coding helps solve simple mathematical checks in a matter of seconds.

Small programs like this may seem basic, but they form the core building blocks of larger applications. Every day, I feel my fundamentals in C are becoming stronger.

Step by step, building my coding journey 🚀


CODING SNIPPET



Also read other blogs at Mayur's Tech Journey

Comments

Popular posts from this blog

The Boy Behind the Percentile: A Memory of 12:07 AM

🚀 Back on Track: Powering Up After Exams!

Scholar Desk : The Ego Issue