Categories

# 5 c number

## C Program to Find the Number of Integers Divisible by 5

This is a C Program which calculates the number of integers divisible by 5 in the given range.

1. This program takes the range as input and finds the number of integers divisible by 5 in the given range.
2. Also finds the sum of all integers that are divisible by 5 in the given range.

1. Take the range as input.
2. Find all the integers that gives remainder zero when divided by 5 and print them as output.
3. Add all the integers that are divisible by 5 and print the sum.
4. Also print the count of integers that are divisible by 5.

Here is source code of the C program to calculate the number of integers divisible by 5. The C program is successfully compiled and run on a Linux system. The program output is also shown below.

1. Take the range as input and store it in the variables num1 and num2 respectively.
2. Firstly initialize the variables count and sum to zero.
3. Using the for loop, find all the integers that gives remainder zero when divided by 5 and print them consecutively.
4. Along with this, increment both the variables i.e increment the variable count by 1 and variable sum by the number that is divisible by 5.
5. Print the variables count and sum as output.

Sanfoundry Global Education & Learning Series – 1000 C Programs.

Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

C Program to Find the Number of Integers Divisible by 5 This is a C Program which calculates the number of integers divisible by 5 in the given range. 1. This program takes the range as input

## –> C program to check whether a number is divisible by 5 and 11 or not

Write a C program to check whether a number is divisible by 5 and 11 or not using if else. How to check divisibility of any number in C programming. C program to enter any number and check whether it is divisible by 5 and 11 or not. Logic to check divisibility of a number in C program.

### Logic to check divisibility of a number –>

–> A number is exactly divisible by some other number if it gives 0 as remainder. To check if a number is exactly divisible by some number we need to test if it leaves 0 as remainder or not.

C supports a modulo operator % , that evaluates remainder on division of two operands. You can use this to check if a number is exactly divisible by some number or not. For example – if(8 % 2) , if the given expression evaluates 0 , then 8 is exactly divisible by 2.

Step by step descriptive logic to check whether a number is divisible by 5 and 11 or not.

1. Input a number from user. Store it in some variable say num .
2. To check divisibility with 5, check if(num % 5 == 0) then num is divisible by 5.
3. To check divisibility with 11, check if(num % 11 == 0) then num is divisible by 11.
4. Now combine the above two conditions using logical AND operator && . To check divisibility with 5 and 11 both, check if((num % 5 == 0) && (num % 11 == 0)) , then number is divisible by both 5 and 11.

Let us implement the logic.

### Program to check divisibility of a number

Let us get little geeky and impress others. You can also write the above divisibility condition as

Think how it works. Still in doubt give 2 minutes on logical NOT operator ! .

Important note: Always remember modulo operator % does not work with float data type.

Write a C program to check whether a number is divisible by 5 and 11 or not using if else. Logic to check divisibility of a number in C programming.