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
yaroslaw [1]
3 years ago
11

Write code for a function that uses a loop to compute the sum of all integers from 1 to n. Do a time analysis, counting each bas

ic operation (such as assignment and ++) as one operation.
Computers and Technology
1 answer:
tekilochka [14]3 years ago
8 0

Answer:

#include<bits/stdc++.h>  

using namespace std;  

int sumOfinteger(int );  

  // Returns sum of all digits in numbers from 1 to n  

int sumOfintegersFrom1ToN(int n)  {  

   int result = 0; // initialize result  

    // One by one compute sum of digits in every number from  

   // 1 to n  

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

       result += sumOfinteger(x);  

   return result;  

}  

  // A utility function to compute sum of digits in a  

// given number x  

int sumOfinteger(int x)  {  

   int sum = 0;  

   while (x != 0)  {  

      sum += x %10;  

       x   = x /10;  }  

   return sum;  }  

  // Driver Program  

int main()  {  

   int n ;  

   cout<<"enter a number between 1 and n : ";

   cin>>n;

   cout << "Sum of digits in numbers from 1 to " << n << " is " << sumOfDigitsFrom1ToN(n);  

   return 0;  }

You might be interested in
You are contacted by a project organizer for a university computer science fair. The project organizer asks you to hold a forum
Usimov [2.4K]

Answer:

Note this:

Nothing beats an open market community!

See below the explanations.

Explanation:

Linux Operating system was created in the early 1990s by Finnish software engineer "Linus Torvalds" and the Free Software Foundation.

1. Why choose Linux over windows.

2. Linux strength.

3. Linux concept.

3 0
3 years ago
Give an explanation of one network connection (it will every helpful​
charle [14.2K]

Answer:

WiFi, Ethernet, Broadband, Dial-up. Any of those.

Explanation:

Network connections are all different. Those listed are some of the many examples of network connections.

7 0
3 years ago
Mary from sales is asking about the plan to implement Salesforce.com's application. You explain to her that you are in the proce
NARA [144]

Answer:

The correct answer to the following question will be Option b ( IT infrastructure).

Explanation:

This refers to either the integrated devices, applications, network infrastructure, as well as facilities needed by an organization This system to function, run, and maintain.

  • Your technology infrastructure seems to be the nervous system, which is accountable for supplying end customers with a streamlined operation.
  • Total control of both your operating system infrastructure ensures you can guarantee the channel's safety is tracked.

Therefore, it will be a part of the design of Mary.

7 0
3 years ago
The tools, skills, knowledge, and machines created and used by humans is known as.
miskamm [114]

Answer:

Human capital

Explanation:

It means the economic value of workers experience and skills

7 0
2 years ago
Help me guys pleassssssssse​
Readme [11.4K]

Answer:

is there a word bank??

Explanation:

8 0
3 years ago
Other questions:
  • Karen has opened a new business and is using Google Display Ads to build awareness of her new products. How does Google Display
    6·1 answer
  • Double clicking a word selects the entire word?
    10·1 answer
  • A forensic investigation discovered that accounts belonging to employees who were terminated numerous years ago were recently us
    9·1 answer
  • Mary is entering her senior year of college. She has a meeting on Friday with her advisor to discuss her career plans.Mary is al
    15·1 answer
  • Which email client feature allows you to store the names and information of people you contact frequently?
    5·1 answer
  • Which statement does not describe how to save a presentation?
    11·1 answer
  • When you need to cut new external threads on a bolt, which of the following tools should you use?
    9·2 answers
  • We have constructed a Player Class for you. Add the following: public static variable: int totalPlayers Static variable should b
    8·1 answer
  • High-level languages must be translated into machine language before they can be executed. _________________________
    10·1 answer
  • In cryptocurrency, a block is only considered valid if it has a.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!