➗ 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
⚙️ 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 🚀
Comments
Post a Comment