Answer to Question #267831 in C for Tania Akter

Question #267831

Write a for loop which will print summation of all the numbers which are divided by 3 and 5 between 30-120.


1
Expert's answer
2021-11-17T12:09:47-0500
#include <stdio.h>

int main()
{
    int sum = 0;
    int i;
    for(i = 30; i <=120; ++i)
    {
        if(i % 3 == 0 && i % 5 == 0)
        {
            sum += i;
        }
    }

    printf("Sum is %d\n", sum);

    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS