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
Anettt [7]
3 years ago
12

Write program to calculate the sum of the following series where in is input by user. (1/1 + 1/2 + 1/3 +..... 1/n)

Computers and Technology
1 answer:
Lorico [155]3 years ago
3 0

Answer:

#here is code in Python.

#read the value n from user

n=int(input("enter the value of n:"))

#variable to store the total sum

sum_n=0

for i in range(1,n+1):

# find the sum of series

   sum_n=sum_n+1/i

#print the sum

print("sum of the series is: ",sum_n)

Explanation:

Read the value of n from user. Create and initialize a variable sum_n with 0. Run a for loop to calculate sum.Initially sum_n is 0, then for value of i=1  1/i will be added to the sum_n.Then in next iteration for i=1, 1/2 added to sum_n. Similarly loop will run util i equals to n.Then sum_n will store the sum of the

series.

Output:

enter the value of n:5

sum of the series is:  2.283333333333333

You might be interested in
Write a program to enter a number and test if it is greater than 45.6. If the number entered is greater than 45.6, the program n
WARRIOR [948]

Answer:

#include <iostream>

using namespace std;

int main ()

{

 float number = 0.0;

 float check = 45.6;

 cout << "Enter Numeber";

 cin >> number;

 if (number > check)

   {

     cout << " Greater than 45.6" << endl;

   }

 else

   {

     cout << " Lesser than 45.6" << endl;

   }

 return 0;

}

Explanation:

declare and initialize float type variable number. Float is used to cater for decimal but not using to much space which is used by double data type. Check value is stored in other variable called check.

Take input from user in number and write an if statement to check whether entered number is less than 45.6 or greater.If number is lesser than check display message "Greater than 45.6" other wise display message "Lesser than 45.6"

5 0
3 years ago
You have been given the job of creating a new order processing system for the Yummy Fruit CompanyTM. The system reads pricing in
Dmitriy789 [7]

Answer:

Invoice.java

import java.util.*;

public class Invoice {

   static final String endPrices = "END_PRICES";

   static final String endInvoice = "END_INVOICE";

   static final String quit = "QUIT";

   public static void main(String... args) {

       Scanner sc = new Scanner(System.in);

<em>        //HashMap to store fruit name as key and price as value </em>

       Map<String, Float> fruits = new HashMap<>();

<em>        //Loop until input is not "END_PRICES" </em>

       while (true){

           String input = sc.next();

<em>            //Come out of loop if input is "END_PRICES" </em>

           if(input.equals(endPrices))

               break;

           float price = Float.parseFloat(sc.next());

<em>            //add fruit to hash map </em>

           fruits.put(input, price);

       }

<em>        //ArrayList to store total cost of each invoice </em>

       List<Float> totalList = new ArrayList<>();

       Float total = 0f;

<em>        //loop until input becomes "QUIT" </em>

       while (true){

           String input = sc.next();

<em>            //Break out of the loop if input is "QUIT" </em>

           if(input.equals(quit)){

               break;

           }

<em>            //Add total price of the invoice to array list and set total to "0f" to store total of next invoice </em>

           if(input.equals(endInvoice)){

               totalList.add(total);

               total = 0f;

               continue;

           }

           int quantity = sc.nextInt();

           total += (fruits.get(input)*quantity);

       }

<em>        //Iterate through all objects in the total Array List and print them </em>

       Iterator itr = totalList.iterator();

       while (itr.hasNext()){

           System.out.printf("Total: %.2f \n", itr.next());

       }

   }

}

7 0
3 years ago
Help! I’ll mark you brainly! Please help me.
nika2105 [10]

Answer:

11. There are four main alignments: left, right, center, and justified

12. Symmetrical balance occurs when equal weights are on equal sides of a composition, balanced around a fulcrum or axis in the center.

13.  Asymmetrical balance results from unequal visual weight on each side of the composition.

14. White space

15. Most modern TVs are 16:9, which causes letterboxing when viewing 21:9 content, and pillarboxing when viewing 4:3 content such as older films or TV broadcasts, unless the content is cropped or stretched to fill the entire display. The Napoléon (1927 film) was released in 4:1 aspect ratio.

16. ??? im sorry idk

17. The Rule of Thirds is the process of dividing an image into thirds, using two horizontal and two vertical lines.

Explanation:

4 0
3 years ago
Which terms represent the two types of client requirements?
stepan [7]

Answer:

FUNCTIONAL AND NON-FUNCTIONAL

Client requirements is a statement of need, might then be prepared which is a first attempt to describe the possible requirements of the project. This may or may not result in the development of a new business project, and even if a project is necessary, it may not require a new building.

Hope this helps you

8 0
3 years ago
Read 2 more answers
Find the mistakes in the following code. Not all lines contain mistakes. Each line depends on the lines preceding it. Watch out
Kazeer [188]

Answer:

Explanation:

A null pointer is pointing to nothing, if we can detect if a pointer is null, we can use an "IF" because a null pointer always going to be false, a null pointer even can block an application, because is a result of undefined behavior, it can even cause problems because the compiler can’t tell whether we mean a null pointer or the integer 0, there is a confusion in this kind of pointers.

5 0
3 years ago
Other questions:
  • a supermarket having a sale on canned foods' the sale includes 12 cans of soup for 10.65 what is the unit price per can of soup
    6·2 answers
  • Identify the six components of an information system. Which are most directly affected by the study of computer security? Which
    8·1 answer
  • When you use the fill handle to copy a formula to adjacent cells, this creates what kind of cell reference?
    5·1 answer
  • Each processor core on a multi core processor generally runs faster than a single core processor
    14·2 answers
  • What is said to be the first mechanical calculator​
    7·2 answers
  • How to deactivate the brainly account?​
    13·1 answer
  • A period in which unemployment is low, business produces many goods and services, and wages are good is called ______.
    8·1 answer
  • 4.2 Lesson Practice​
    8·2 answers
  • Write a format operation that builds a string for the float variable amount that
    11·1 answer
  • What can handle work that is hard on a person and could cause repetitive injuries?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!