Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started