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]
2 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:
Alex2 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
A ____ error occurs when the javascript interpreter encounters a problem while a program is executing.
Leya [2.2K]
It is a runtime error thart occurs when <span>the javascript interpreter encounters a problem while a program is executing.</span>

5 0
3 years ago
Allocate 100 integers and assign the resulting pointers to the elements of ip_arr. Initialize each integer value to -1.
dmitriy555 [2]

Answer:

#include <iostream>

using namespace std;

int main() {

   int *ip_arr,n;//pointer name inp_arr and integer n to store the size.

   cin>>n;//size.

   for(int  i=0;i<n;i++)

   ip_arr[i]=-1;//assigning -1 to every element.

  for(int i=0;i<n;i++)

  {

       cout<<ip_arr[i]<<" ";//printing every element.

  }

return 0;

}

output:-

100

-1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1  

Explanation:

I am taking input of size.You should enter 100 for 100 values which have value -1.

5 0
3 years ago
A cookie is.... a. an illegal use of information about a customer b. a feature of a Web site designed to attract children c. a f
Elodia [21]

Answer:

C. A file that a Web site stores on a visitor's computer

Explanation:

Have a nice day! :)

3 0
2 years ago
Which statement about technology before the invention of the printing press is true?
marta [7]

Answer: See explanation

Explanation:

You didn't give the options to the question and I searched and couldn't find the particular question.

Here, are some of the things about technology before the invention of the printing press.

1. Before printing press, monks copied books such as bibles as they'll copy calligraphy and illustrations in order for them to spread the messages in the Bible across to people.

2. Before printing press, oral communication was the way that people communicated with each other.

3. Drawings and writings were done by hand before printing press.

4. Before the invention of printing press, in order to transcribe books, different materials that were used include wax, parchment, clay and papyrus.

8 0
2 years ago
What is the name of this tool and what can it be used for?<br> Thanks!!
Iteru [2.4K]
That is a corqet tool it is used for fixing tires
6 0
3 years ago
Other questions:
  • Which payment type is best if you are trying to sick to a budget?
    15·1 answer
  • How do you uninstall sc update?
    13·2 answers
  • How can ascii be used to represent characters in computer system
    7·1 answer
  • "Consider yourself driving with 60 miles/hour in a city that has only grid like streets, and your GPS is broken.The specificatio
    12·1 answer
  • What is a row of data in a database called?<br> Field<br> File<br> Record<br> Title
    10·1 answer
  • Write a while loop that adds the first 100 numbers (from 1 to 100) together. To do so, use a while loop that continues while the
    12·2 answers
  • A common use-case for dictionaries is to store word counts. Let's modify our program below to store the count for each unique wo
    9·1 answer
  • Justine was interested in learning how to play the piano. Before she was allowed to even play the piano, she has had to learn
    15·2 answers
  • In a ______topology, every device has exactly two neighbors for communication purposes. A failure in any cable or device can tak
    15·2 answers
  • Select all the correct answers.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!