BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

C program to print numbers divisible by 3 and 5 from 1 to 100

Last Updated: May 16, 2024 by Chaitanya Singh | Filed Under: C Programs

In this article, we will see a simple C program to print all the numbers between 1 and 100 that are divisible by 3 and 5 both.

C Program to print numbers that are divisible by 3 and 5 between 1 and 100

The program iterates through from numbers 1 to 100 using for loop. In this loop, it checks each number whether it’s divisible by 3 and 5 both using modulo operator %. If the remainder after dividing the number by 3 and 5 is zero (in both cases), then this number is divisible by both 3 and 5, program prints this number.

#include <stdio.h>

int main() {
printf("Numbers between 1 and 100 divisible by both 3 and 5 are:\n");

// Loop through numbers from 1 to 100
for (int i = 1; i <= 100; i++) {
// Check if the number is divisible by both 3 and 5
if (i % 3 == 0 && i % 5 == 0) {
printf("%d\n", i);
}
}

return 0;
}

Output:

Numbers between 1 and 100 divisible by both 3 and 5 are:
15
30
45
60
75
90

Top Related Articles:

  1. C Program to concatenate two strings without using strcat
  2. C Program to find Palindrome numbers in a given range
  3. C Program to check Armstrong number
  4. C Program to validate a given date
  5. C Program to Find ASCII value of a Character

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

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

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap