Question: Write a C program that, given an integer n as input, determines the sum of those natural numbers less than or equal to n that

Write a C program that, given an integer n as input, determines the sum of those natural numbers less than or equal to n that are multiples of 3, or of 5, or of both 3 and 5.

Example

If n = 20, then the sum is 3 + 5 + 6 + 9 + 10 + 12 + 15 + 18 + 20 = 98.

  • The filename containing your C program must be named Program_1.c.
  • Your program's input and output must look as much as possible like the sample runs shown below (including, but not necessarily limited to, wording, punctuation, horizontal & vertical spacing, and indentation).

Sample Run # 1

This program, given an integer N as input, determines the sum of those natural numbers less than or equal to N that are multiples of 3, or of 5, or of both 3 and 5. Please enter an integer N : 20 The sum is 98.

Sample Run # 2

This program, given an integer N as input, determines the sum of those natural numbers less than or equal to N that are multiples of 3, or of 5, or of both 3 and 5. Please enter an integer N : 9232 The sum is 19889114.

Sample Run # 3

This program, given an integer N as input, determines the sum of those natural numbers less than or equal to N that are multiples of 3, or of 5, or of both 3 and 5. Please enter an integer N : -10 Since there are no natural numbers <= -10, the sum is 0.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!