1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
otez555 [7]
3 years ago
14

Write a program that takes an integer n as a parameter and sums all of the multiples of 2 or 5 from 1 to n. For example, if n =

11, the result would be 2 + 4 + 5 + 6 + 8 + 10 = 35.
Computers and Technology
1 answer:
Alex3 years ago
4 0

Answer:

// here is code in c++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main() {

// variable

int num;

int tot_sum=0;

cout<<"enter a number: ";

// read the value of n

cin>>num;

// check the multiple of 2 or 5 from 1 to n

for(int x=1;x<=num;x++)

{

// if multiple of 2 or 5 then add them

   if(x%2==0 ||x%5==0)

   {

       tot_sum=tot_sum+x;

   }

}

// print the sum

cout<<"sum of multiple of 2 or 5 is:"<<tot_sum<<endl;

return 0;

}

Explanation:

Read the number "n" from user.Check every number from 1 to n, if it is a multiple of 2 or 5 then add them to "tot_sum".When the for loop end, "tot_sum" will have sum of all the number which are either multiple of 2 or 5.Print the sum.

Output:

enter a number:11

sum of multiple of 2 or 5 is:35

You might be interested in
Write an application that encodes English-language phrases into pig Latin. Pig Latin is a form of coded language. There are many
deff fn [24]

Answer:

Answer has been attached to this response as a source code file saved as "PigLatinWord.java"

Explanation:

Explanation has been added to the source code in the form of comments. Please go through the comments in the code.

Hope this helps!

Download java
3 0
4 years ago
5. Create a vector called to20 that goes from 1 to 20 (use the range notation). Now create a variable called end that goes from
Lady_Fox [76]

Answer:

creating vector:

code:  

to20 <-c(1:20) #creating to20 vector

end <-c(40:50) #creating end vector

to50 <-c(to20,21:30,end) # creating to50 vector

print(to50) # printing to50 vector

Explanation:

8 0
3 years ago
Follow me on insta Aaftabkhan_7​
liq [111]

Answer:

stop just stop this app is for studying  not for ur insta

Explanation:

8 0
3 years ago
Read 2 more answers
A print server uses a print ________ as a software holding area for jobs waiting to be printed.
vichka [17]

Answer:

spooler

Explanation:

A print server uses a print spooler as a software holding area for jobs waiting to be printed.

8 0
2 years ago
Read 2 more answers
Which one of the following is NOT a type of reference method that uses a terminal digit system? 1) Account payables 2) Medical r
lana66690 [7]
I believe #4 , this uses automational redirect
7 0
4 years ago
Other questions:
  • You will use the _____
    15·2 answers
  • Write qbasic code for given pattern<br><br>NEPAL<br>. EPA<br>. P​
    12·1 answer
  • Why did the chicken cross the playground
    7·2 answers
  • How many bits long is a autonomous system number?
    13·1 answer
  • p25: File Write and Read1) User enters a file name (such as "myMovies.txt").2) User enters the titles of 4 of their favorite mov
    12·1 answer
  • Develop a Java application that provides program output in a logical manner and incorporates appropriate data types. Similar to
    6·1 answer
  • Suppose the daytime processing load consists of 65% CPU activity and 35% disk activity. Your customers are complaining that the
    15·1 answer
  • Which type of formatting would you apply to spreadsheet data so that each cell is outlined?
    5·1 answer
  • Portable Document Format is a proprietary document file type created by Adobe Systems that is compatible with most computer syst
    7·1 answer
  • What are common considerations businesses need to make before purchasing new computers? Check all of the boxes that apply.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!