Write a c program to find the sum of all numbers between 10 and 100 that are divisible by 7.\
Answers
Answered by
0
The sum of (10 to 100 number), which is divisible by 7.
Output:
Sum: 728
Explanation:
Program to calculate sum of (10 to 100 number), which is divisible by 7 as follows:
Program:
#include <stdio.h> //defining header file
int main() //defining main method
{
int t,sum=0; //defining integer variable
for(t=10;t<=100;t++) //loop for count 10 to 100
{
if(t%7==0) //check value is divisable by 7
{
sum=sum+t; //calculate sum
}
}
printf("Sum: %d",sum); //print calculated value
return 0;
}
Description of the above code as follows:
- The header file is defined in the above C language code, then the main method is declared, which computes all values.
- In the main method the two integer variable "t and sum" is defined, in which variable "t" is used to for loop to count the value from 10 to 100, inside the loop if block is declared.
- In if block, it checks value is divisible by 7. if this condition is true, it will add value in the sum variable and uses the print function to print sum variable value.
Learn more:
- Program in C: brainly.in/question/14470592
- Calculate velocity in C: https://brainly.in/question/15376188#
Similar questions