PROBLEM
Write a program calculating summation of (multiples of 3 or 5).
This c problem is taken by me from: (https://projecteuler.net/problem=1)
SAMPLE RUN:
In addition to problem, i printed result on the screen.
SOLUTION
You can copy codes below to your compiler to execute.
#include <stdio.h>
int main(void) //main function.
{
int sum = 0; //this variable will hold summation of multiples of 3 or 5 below 1000.
for (int k = 3; k < 1000; k++) //this loop will find the summation of multiples of 3 or 5.
if (k % 3 == 0 || k % 5 == 0) //this comparison will determine if k is multiple of 3 or 5 or not.
sum = sum + k; //it will calculate summation of ks which are multiples of 3 or 5.
printf("Summation of multiples of 3 or 5 below 1000 is %d", sum); //it will print the summation on the screen.
return 0;
}