How to write a C program to find and sum all numbers divisible by 9 between 100 || Free Code Center

How to write a C program to find and sum all numbers divisible by 9 between 100


Welcome to our comprehensive guide on finding and summing all numbers divisible by 9 between 100 and a user input in a C program. In this article, we will provide you with a step-by-step approach to solve this problem efficiently and effectively. By following our instructions, you will be able to create a high-performing C program that not only solves the task at hand but also stands out from the competition. So, let’s dive right in!

Understanding the Problem

Before we start writing the code, it’s essential to have a clear understanding of the problem statement. We are tasked with finding and summing all numbers that are divisible by 9 within a specific range. The lower bound of the range is fixed at 100, while the upper bound will be determined by the user’s input.


To accomplish our goal, we will follow a systematic algorithm that ensures accuracy and efficiency in our program. Here are the steps we will take:

Step 1: Accept User Input

We begin by taking input from the user to determine the upper bound of the range. This value will be stored in a variable for later use.

Step 2: Initialize Variables

Next, we initialize a variable to hold the sum of the divisible numbers and another variable to iterate through the range starting from 100.

Step 3: Iterate Through the Range

Using a loop, we iterate through the range of numbers starting from 100 up to the user-defined upper bound. For each number, we check if it is divisible by 9 using the modulo operator (%). If the number is divisible, we add it to the sum variable.

Step 4: Display the Result

Once the loop has finished iterating through the range, we display the final sum of all the divisible numbers to the user.

How to write a C program to find and sum all numbers divisible by 9 between 100


Example 1:

Now that we have a clear algorithm in mind, let’s implement it in C code. Here’s a sample implementation that you can use as a reference:

#include <stdio.h>

int main() {
    int userInput, sum = 0;

    printf("Enter the upper bound: ");
    scanf("%d", &userInput);

    for (int i = 100; i <= userInput; i++) {
        if (i % 9 == 0) {
            sum += i;

    printf("The sum of numbers divisible by 9 between 100 and %d is: %d\n", userInput, sum);

    return 0;

Example 2:

void main ()
    int i,n,disvi=1,sum=0;
    scanf ("%d",&n);
    printf("Numbers between 100 and 200:");
    for (i=100;i<=n;i++){
printf(" %d ",i);


    printf("\nThe sum:%d",sum);


Congratulations! You have successfully created a C program that finds and sums all the numbers divisible by 9 between 100 and the user input. By following the steps outlined in this article, you now have a competitive advantage in outranking other websites offering similar content.

Remember, providing valuable and comprehensive articles is just one aspect of improving search rankings. To further enhance your website’s visibility, we recommend delving into the world of search engine optimization (SEO). Understanding SEO best practices will help you optimize your content, increase organic traffic, and ultimately achieve higher rankings on search engine result pages (SERPs).

C programming tutorial

Leave a Comment

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

Scroll to Top
NEW TOXIC ROCKET CYCLE DECK in Clash Royale 2023 Best Deck in Clash Royale Best Deck for Arena 8 in Clash Royale Best Hog deck for Pro players Best Clash Royale Deck