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

## Introduction

This is a complete guide on how to write a C program that identifies all numbers between 100 to N (input by user ) and finds the sum of each number which is divisible by 9. In this post, we will explain you how to solve this problem step by step in an efficient and effective way. Following our guide, you will implement an effective C program that is able to not only fulfill the problem with top notch performance but also outshine other solutions. So, letâ€™s dive right in!

Understanding the Problem

It is important to know the problem statement before we begin writing the code. Calculate the sum of all numbers from 20 to 30, if they are divisible by 9. Min -> The smallest number the range limit can have, which is always going to be 100Max -> The User will decide what this value means

Algorithm

It is essential that our implementation operates within the scope of this algorithm to be accurate and efficient in carrying out our goal. These are the steps we follow:

Step 1: Accept User Input

We ask for an input from the user on top of which you would like your number to be generated. This value is wanted to be saved into a variable for further reference.

Step 2: Initialize Variables

We then assign to a crossSum, which will hold the sum of factorials a new variable known as n_Start going through the range which starts from 100.

Step 2: Go Through the Range

Rather, we loop through the numbers 100 up to whatever value the user wants (they are able to enter different max values in a menu). I Use the modulo operator (%) to check if a number is divisible by 9 for each number. If it is divisible, we add it to the sum variable.

Step 4: Display the Result

Once the loop has iterated through all of the numbers in the range, we show to the user what is the final sum of all this divisable numbers.

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

## Implementation

**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:**

#include<stdio.h>

void main ()

{

int i,n,disvi=1,sum=0;

scanf ("%d",&n);

printf("Numbers between 100 and 200:");

for (i=100;i<=n;i++){

if(disvi=(i%9==0)){

printf(" %d ",i);

sum=i+sum;

}

}

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

}

## Conclusion

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.

Can you be more specific about the content of your article? After reading it, I still have some doubts. Hope you can help me.