C program to find the number of integers divisible by 5 between the given range N1 and N2, where N1 < N2 and are integers. Also find the sum of all these integer numbers that divisible by 5 and output the computed results

by Nideesh C on April 12, 2011 · 0 comments

in C Programming




/* C program to find the number of integers divisible by 5 between the given range N1 and N2, where N1 < N2 and are integers. Also find the sum of all these integer numbers that divisible by 5 and output the computed results */

#include <stdio.h>
#include <conio.h>

void main()
{
int i, N1, N2, count = 0, sum = 0;

clrscr();

printf (“Enter the value of N1 and N2\n”);
scanf (“%d %d”, &N1, &N2);

/*Count the number and compute their sum*/
printf (“Integers divisible by 5 are\n”);

for (i = N1; i < N2; i++)
{
if (i%5 == 0)
{
printf(“%3d,”, i);
count++;
sum = sum + i;
}
}

printf (“\nNumber of integers divisible by 5 between %d and %d = %d\n”,
N1,N2,count);
printf (“Sum of all integers that are divisible by 5 = %d\n”, sum);

}   /* End of main()*/
/*—————————–
Output
Enter the value of N1 and N2
2
27
Integers divisible by 5 are
5, 10, 15, 20, 25,
Number of integers divisible by 5 between 2 and 27 = 5
Sum of all integers that are divisible by 5 = 75
——————————————————*/

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. C program to find the sum of odd numbers and sum of even numbers from 1 to N. Output the computed sums on two different lines with suitable headings
  2. C program to find the GCD and LCM of two integers output the results along with the given integers. Use Euclids’ algorithm
  3. Write a C program to find the sum of ‘N’ natural numbers
  4. C program to generate and print prime numbers in a given range. Also print the number of prime numbers
  5. Sample – Program to enter three integers and output the biggest integer.

Leave a Comment

Previous post:

Next post: