Write a program to display the multiple of 5 from 25 to 1000.
Answers
Answer:
I am using python for the answer.
for i in range(25, 1001):
if i%5 == 0:
print(i)
Explanation:
We are iterating over a range from 25 to 1000 then checking if remainder of i divided by 5 is 0, if it is then we are printing this value.
Output will look like-
25
30
35
40
...
1000
Heyo!
C/C++
/*
* C/C++ program to print the multiples of 5 starting
* from 25 to 1000.
*/
#include <stdio.h>
int main()
{
// Declare all required variables
int root, head, num;
root = 25; // base number from which to start checking from
head = 1000; // head number to stop checking when current number = head number
// Create a for loop to loop through all the number
// in-between root (25) to head (1000)
for (num = root; num <= 1000; num++)
{
// If the remainder of the current number when divided by 5 is 0 than,
// print the number to the console/output.
if (num % 5 == 0)
{
printf("%d\n", num);
}
}
// End the program
return 0;
}
Python
for num in range (25, 1001):
if ( num % 5 == 0):
print(num)
Output is provided in the attachments!
Edit: Added python program.
Hope this helps you!