Users Online

· Guests Online: 36

· Members Online: 0

· Total Members: 188
· Newest Member: meenachowdary055

Forum Threads

Newest Threads
No Threads created
Hottest Threads
No Threads created

Latest Articles

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

C Program to Find the Number of Integers Divisible by 5

This C Program calculates the number of integers divisible by 5. This program checks if the given number is divisible by 5 and then prints an appropriate message.
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.

/*
* C program to find the number of integers divisible by
* 5 between the given range num1 and num2, where num1 < num2.
*
* Also find the sum of all these integer numbers which are divisible
* by 5 and display the total.
*/
#include
void main()
{
int i, num1, num2, count = 0, sum = 0;

printf("Enter the value of num1 and num2 \n");
scanf("%d %d", &num1, &num2);
/* Count the number and compute their sum*/
printf("Integers divisible by 5 are \n");
for (i = num1; i < num2; i++)
{
if (i % 5 == 0)
{
printf("%3d,", i);
count++;
sum = sum + i;
}
}
printf("\n Number of integers divisible by 5 between %d and %d =
%d\n", num1, num2, count);
printf("Sum of all integers that are divisible by 5 = %d\n", sum);
}

$ cc pgm18.c
$ a.out
Enter the value of num1 and num2
12 17
Integers divisible by 5 are
15,
Number of integers divisible by 5 between 12 and 17 = 1
Sum of all integers that are divisible by 5 = 15

Comments

No Comments have been Posted.

Post Comment

Please Login to Post a Comment.

Ratings

Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Render time: 0.68 seconds
10,255,126 unique visits