Code :
#include<stdio.h>
int main(){
int i, sum = 0;
for (i = 101; i < 200; i++)
{
if(i%5==0){
sum = sum+i;
}
}
printf("Sum : %d",sum);
return 0;
}
Output :
Sum : 2850
Explanation :
Declare a variable i and sum. Initialize sum is equal to zero. sum is used to store the value of sum and i is used to iterate through the for loop. Declare for loop with range between 100 to 200. Using if statement check whether number is divisible by 5 or not. If divisible by 5 then add it to sum. At the end print the value of sum.
0 Comments
Ask Your Queries in the comments