numbers (n1 and n2) from the all the numbers in entered 4) Write a complete C/c+
ID: 3702129 • Letter: N
Question
numbers (n1 and n2) from the all the numbers in entered 4) Write a complete C/c++ program Having done so, th two integer num to enter n2 (25 Points) e program would calculate and display all the numbersin 2 from integer numbers (i.e. n1 to n2) that are divisible by 2 and 5. Notice that the ween the entser not need to check this. as a greater number than n1 in all cases - which means you do SAMPLE RUN Enter n1: 1 Enter n2: 100 The nunbero that are divisible by 2 and 5 in between 1 and 1 10 20 30 40 50 60 70 80 90 100 Hint: Notice that nl and n2 are not always 1 and 100. This is just given as an example in the SAMPLE RUN can enter whatever number they want.Explanation / Answer
Program:
#include <stdio.h>
void main()
{
int i, n1, n2, count = 0, sum = 0;
printf("Enter the numbers of num1 and num2 ");
scanf("%d %d", &n1, &n2);
printf("numbers divisible by 2 and 5 are ");
for (i = n1; i <=n2; i++)
{
if (i % 2 == 0 && i % 5 == 0)
{
printf("%3d ", i);
count++;
}
}
printf(" The nunbers that are divisible by 2 and 5 in between %d and %d = %d ", n1, n2, count);
}
Output:
Enter the numbers of num1 and num2 :1 100
numbers divisible by 2 and 5 are
10
20
30
40
50
60
70
80
90
100
The nunbers that are divisible by 2 and 5 in between 1 and 100 = 10
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.