Assume a file containing a series of integers is named numbers.txt and exists on the computer’s disk. Write a program that reads all of the numbers stored in the file, calculates their total and displays it.


Very Important: The file could have any number of numbers, so you need to use a loop to process the data in the file

Answers

Answer 1

#include <iostream>

#include <fstream>

using namespace std;

int main(){

   int x, sum=0;

ifstream f("numbers.txt");

while(!f.eof()){

       f >> x;

       sum +=x;

}

cout << "Sum : " << sum;

}

This is a C++ program.

Next time be more precise on the programming language you want


Related Questions

Insert the missing code in the following code fragment. This fragment is intended to implement a method to set the value stored in an instance variable.
Public class Employee
{
Private String empID;
Private boolean hourly;
) . .
_______
{
Hourly = isHourly;
}
}
A) public void setHourly(String isHourly)
B) public void getHourly()
C) public boolean getHourly()
D) public boolean setHourly(boolean isHourly)

Answers

Answer:

A)

Explanation:

In this code example the missing piece of code would be...

public void setHourly(String isHourly)

This piece of code is creating a function called setHourly which takes in one String variable as it's parameter. Based on the rest of the code, the function takes that parameter variable and places it into an instance variable called Hourly which can be used when the function is called.

Write a test program that prompts the user to enter a two dimensional array and displays the location of the smallest element in the array.

Answers

Answer:

def element_loc():

   is_end = 'n'

   dimen2 = []

   while is_end == 'n':

       par1 = input("Enter rows and columns: ").split(",")

       part = [int(i) for i in par1]

       dimen2. append(part)

       is_end = input("Do you want to add more rows? y/n: ")

   mini = list()

   for i in dimen2:

       mini. append(min(i))

   result = min(mini)

   row_index = mini. index(result)

   col_index = dimen2[row_index]. index(result)

   print("Row: ", row_index, "Col_index: ", col_index)

element_loc()

Explanation:

The python program solution above prompts users for the two-dimensional array and then the rows of the array are compared with the minimum value stored in another list or array. The row index and the column index are gotten from the mini and dimen2 arrays respectively and are displayed as the position of the minimum value in the two-dimensional array.

If a function is called more than once in a program, the values stored in the function's local variables do not _________ between function calls. g

Answers

Answer:

persist

Explanation:

Calling a function Within a program, can be regarded to as specifying of the name of the function when it is within a statement or it could be by the function itself, it possible for a particular function to call another function, in a case wherby a function returns a value, assignment or using the value to variable is not necessary. It should be noted that If a function is called more than once in a program, the values stored in the function's local variables do not persist between function calls

A short circuit can cause _______ because there is nothing in the circuit to limit the current and absorb the electrical energy. Heat builds up quickly in the wire and power supply.

Answers

Answer:

Fire

Explanation:

You'll get a giant spark. The electricity will flow freely causing over-heating or fire.

Write an if statement assigns 20 to the variable y, and assigns 40 to the variable z if the statemnet x is greater than 100​

Answers

Answer:

y=20 z=40 x>100

Explanation:

not sure if this is correct but yes

How is fraudulent email spread that makes it so difficult to track?

Answers

The owner of the email could be using a VPN.

write passage on computer virus​

Answers

In more technical terms, a computer virus is a type of malicious code or program written to alter the way a computer operates and is designed to spread from one computer to another. A virus operates by inserting or attaching itself to a legitimate program or document that supports macros in order to execute its code.

Answer:

A computer virus is a relatively small program that attaches itself to data and program files before it delivers its malicious act. There are many distinct types of viruses and each one has a unique characteristic. Viruses are broken up into to main classes, file infectors and system or boot-record infectors.

hope it helps

high level languages are closer to machine language than humans yes or no​

Answers

they are closer to human languages and further from machine so, no.

Answer:

yes

Explanation:

because they were built from humans

A SQL data source is a control that can be used to get data from a SQL ________________ file such as a Microsoft SQL Server file. g

Answers

Answer:

The answer is "Data"

Explanation:

A Data source is essentially the wellspring of the Data. It tends to be a document, a specific Database on a DBMS, or even a live Data feed. The Data may be situated on a similar PC as the program, or on another PC some place on an organization

At least, every SQL server database has two working operating system records: a Data filet and a log Data. Data files contain Data and items, for example, tables, files, put away methodology, and perspectives. Log records contain the data that is needed to recuperate all exchanges in the Database. Data files can be assembled in file groups for portion and organization purposes.

write the code that writes access granted if the correct password, swordfish is entered and access denied! otherwise

Answers

In python 3.8:

if input("Enter password: ") == "swordfish":

   print("access granted")

else:

   print("access denied!")

JAVA...Write a statement that calls the recursive method backwardsAlphabet() with parameter startingLetter.
CODE BELOW
public class RecursiveCalls {
public static void backwardsAlphabet(char currLetter) {
if (currLetter == 'a') {
System.out.println(currLetter);
}
else {
System.out.print(currLetter + " ");
backwardsAlphabet(--currLetter);
}
}
public static void main (String [] args) {
char startingLetter;
startingLetter = 'z';
/* Your solution goes here */
}
}

Answers

Answer:

RecursiveCalls.backwardsAlphabet(startingLetter);

Explanation:

The statement that is needed is a single-line statement. Since the class RecursiveCalls is already in the same file we can simply use that class and call its function without making a new class object. Once we call that class' function we simply pass the variable startingLetter (which is already provided) as the sole parameter for the function in order for it to run and use the letter 'z' as the starting point.

       RecursiveCalls.backwardsAlphabet(startingLetter);

What single awk command can be used to display all the login names and their associated numerical user IDs

Answers

Answer:

Used the command syntax; awk -F":" '{ print "username: " $<number location> "\t\tuid:" $<number location> }' <target folder>

Explanation:

Linux operating system is a fast open-source computer platform for programmers and network administrators. Its system is arranged in a hierarchical tree structure with the root represented as "/" (for absolute path).

The passwd is a folder in the Linux OS that holds the login details of all users in the system network. The 'awk' is one of the commands used to get information from a file in a folder. It prints out the result by specifying the location of the values (like the username and user id) as a variable (with prefix '$') and then the target folder.

In order to be an effective employee who knows recent information on loans and laws, in what topic should your information be current?

regional trends

industry politics

regional politics

industry trends

Answers

Answer:

industry politics

Explanation:

In order to be an effective employee who knows recent information on loans and laws, your information should be current in industry politics.

This ultimately implies that, an employee who wants to be well-informed and knowledgeable on recent informations on loans and laws, is saddled with the responsibility of gathering and sourcing for informations through industry politics. Thus, the employee must have been involved in working with various industry leaders and most likely to have interacted with various employees working there.

Industry politics can be defined as a group of policies, standards and regulations set by the government to promote and facilitate competitiveness among the private and publicly owned industries.

Answer:

industry politics

Explanation:

the other person is first and correct mark him brainliest!

The inFS.open(str) function has a string parameter str that specifies the _____ of the file to open.

Answers

Answer:

str represents the name of the file to open

Explanation:

Required:

What does str represents in the above syntax

Before the inFS function can be used to access or read or write into a file, the file name has to be specified.

This could be done in any of the following ways:

1. inFS.open("abc.txt")

2. str = "abc.txt"; inFS.open(str);

In (1), the file name is specified directly into the function

While in (2), the filename is passed into a string variable which is then further passed to the inFS function.

In the case of this question, method 2 is used and the str represents the name of the file

ong answer, but make sure to provi
you
reasoning
Sales Company:
W.D. Widgets is a small company that sells widgets. They're mostly made up of salespeople who work with lots of clients.
You've taken over as the sole IT person for this company of 80-100 people.
R teils you to provision a machine for a new employee, you order the hardware directly from a business vendor.
You keep one or two machines in stock, in case of emergency. The users receive a username that you generate for them.
You then give them an orientation on how to login when they start. You currently manage all of your machines using
Windows Active Directory. The company uses only Windows computers. When a new computer is provisioned, you have
to nistallots of sales-specific applications manually onto every machine. This takes a few hours of your time for each
15
machine. When someone has an IT-related request, they email you directly to help them.
Almost all software is kept in-house, meaning that you're responsible for the email server, local machine software, and
instant messenger. None of the company's services are kept on the cloud.
Customer data is stored on a single file server. When a new salesperson starts, you also map this file server onto their
local machine, so that they can access it like a directory. Whoever creates a folder on this server owns that folder and
everything in it. There are no backups to this critical customer data. If a user deletes something, it may be lost for
everyone.

Answers

Answer:

Umm just go what your gut tells you to do

Explanation:

What is the information that oranges contain vitamin C considered?

Answers

Answer:

Nutritional Information or Nutritional facts.

Explanation:

They are on most foods, on medicines it's called Drug Facts, and on vitamins it's called Supplementary facts!

What is closed soruce nonproprietary hardware and software based on publicly known standards that allow third parties to create

Answers

Answer:

open system

Explanation:

An open system is a system that sets open-source standards and promotes the interoperability and portability standards between systems developing and running open-source programs.

An open-source application is a program in which its source code is readily available and free for public use and upgrade. Unlike closed-source, its users can add or update the features of the source code.

How many fnaf games did Scott Cawthon make?

Answers

Answer:

8 but he is making FNaF security breach

Explanation:

there is FNaF VR help wanted

Answer:

8 or 10

Explanation:

Which item is essential to know before sketching a navigation menu flowchart?
template specifics, such as horizontal or vertical menu layout
whether or not the site will implement a search feature
all of the pages in the site and the content each page will contain
who will be using the site and the design theme selected for them

Answers

Answer:

A, template specifics, such as horizontal or vertical menu layout

Explanation:

Answer:

D. who will be using the site and the design theme selected for them

Explanation:

I am doing the exam right now.

While your hands are on home row, both of your thumbs are on _____.

Answers

Answer:

While your hands are on home row, both of your thumbs are on Space-barI know this will definitely help✍️✍️✍️

____________are the video images provided for editor to cut to and from instead of making viewers watch talking heads
Blank 1:

Answers

Answer:

The Scripts

Explanation:

Using direct mapping, consider a 16-bit memory addresses, and a cache with 64 blocks, where each block is 8 bytes. What is the size of offset, block, and tag

Answers

Answer:

Tag          Block             Offset

 7               6                   3

Explanation:

Using direct mapping hashing:

Memory address size = 16 bits

Number of cache blocks = 64

Size of each block = 8 bytes

Thus;

Offest field = size of each block = 2^{3} = 3 bits

Number of blocks = 64 = 2

Thus, the index field is = 2^{6} = 6 bits of block

Tag filed is of size = 16 - (3+6) = 7 bits of tag

1) Write a statement that defines an array of four integers named miles. The array should be initialized with the values 1, 5, 9, and 22.
2) Write a statement that defines an array of string objects nameddirections. The array should be implicitly sized, with an initialization list containing the values "Up", "Down", "Left", and "Right.

Answers

Answer:

Explanation:

The following code statements are written in Java and are simple one line statements that can be into any Java code or function. The first code statement creates a simple integer array with 4 predefined values initialized.

1) int[] miles = {1,5,9,22};

The second code statement creates a simple String array with four-string objects in it.

2) String[] nameddirections = {"Up", "Down", "Left","Right"};

When multiple architects work on a construction plan, which section of a construction plan will help them keep track of when the changes are made and by whom?
A.
framing plan
B.
schedule
C.
title block
D.
bill of materials

Answers

Answer:

I believe that it is . A. framing plan

Explanation:

But I am not certain But I do know that it IS NOT B..

Answer:

the answer is schedule!!!

Explanation:

The ____ represents units of work application software performs in terms of its demand for low-level hardware services.

Answers

Answer:

application demand model

Explanation:

A part-time job performed while in high school must have the approval of your school counselor.
False
True

Answers

Answer:

False, it only needs approval of your parents/guardian

May I have brainliest please? :)

Answer:

False

Explanation:

What does using nesting in HTML allow you to do?
Style the HTML automatically
Automatically add missing opening or closing tags to the HTML
Prevent any misspelled tag keywords from appearing in the HTML
Improve readability and find and fix problems more easily

Answers

Answer:

The answer to this question is given below in the explanation section.

Explanation:

The given options to this question are:

Style the HTML automatically Automatically add missing opening or closing tags to the HTML Prevent any misspelled tag keywords from appearing in the HTML Improve readability and find and fix problems more easily

The correct option to question is Option 1. i.e.

Style the HTML automatically.

Nesting HTML refers to enlist the HTML tage within HTML tag.

For example, the <p> tag is used to insert paragraph text. You can insert nesting HTML tags within the paragraph tag to style the pragraph.

such as:

<p>

<b>

This is a paragraph

</b>

</p>

The above HTML code bold the paragraph.

While the options are not correct because:

Nesting HTML does not allow to insert missing opening or closing tags to the HTML and also does not prevent appearing the misspelled tag keyword. Nesting HTML does not improve readability and find and fix the problem easily because nesting HTML mostly made the HTML more complex in terms of readability.  

Write a class that specify the characteristics of a car, like type (sedan, jeep, mini, SUV, etc), gear (auto, manual), maximum speed (mph), average fuel consumption (mpg), etc. Create few objects to illustrate your desired cars.

Answers

Answer:

Answered below

Explanation:

This is written in Kotlin programming language.

//Creating the class Car. The primary //constructor declares car's properties which //are initialized when it's objects are created.

class Car(

val type: String,

val gear: String,

val maxSpeed: Double,

val avgFuelConsumption: Double)

//Creating several objects of car.

val sedan: Car = Car("sedan", "auto", 23.4, 500)

val jeep: Car = Car("jeep", "manual", 40, 350)

val mini: Car = Car("mini", auto, 26.7, 86, 234)

Define a toString prototype method that returns the cat's name, gender, and age separated by semicolons.

Answers

Answer:

Following are the program to this question:

import java.util.*;//import package for user input

public class Main//defining main class

{

public static String Cat (String name, String gender, int age)//defining string method Cat that accept parameter value

{

return name + ';' + gender + ';' + age;//return parameter value

}

public static void main(String[] args) //defining main method

{

   String name,gender;//defining String variable

   int age;//defining integer variable

   System.out.println("Enter name, gender and age: ");//print message

   Scanner obx=new Scanner(System.in);//creating Scanner class object for user input

   name=obx.next();//input name value

   gender=obx.next();//input gender value

   age=obx.nextInt();// input age value

   System.out.println(Cat(name,gender,age));//print return method value

}

}

Output:

Enter name, gender and age:  

dani

Female

12

dani;Female;12

Explanation:

In the above-given code, a string method Cat is declared, that accepts three variable "name, gender, and age", inside the method return keyword is used that returns the parameter values.

In the main method, the above parameter variable is declared, which is used to input value from the user-end, and used the print method to print its return value.

Dictionaries You are given a dictionary consisting of word pairs. Every word is a synonym the other word in its pair. all the words in the dictionary are different. after the dictionary there's one more word given . Find a synonym for him. Given a list of countries and cities of each country. then given the names of the cities. for each city specify thr country in which it is located.... python

Answers

Answer:

To add values to a dictionary, specify the dictionary name with the key name in quotes inside a square bracket and assign a value to it.

 dictionary_name["key_name"] = value

Explanation:

A python dictionary is an unindexed and unordered data structure. It's items a key-value pair separated by a colon and the entire dictionary items are enclosed in curly braces. Unlike a list, the dictionary does not use an index but uses the key to get or add a value to the dictionary.

Answer:

Python answer:

dict = {}

times = int(input())

for _ in range(times):

   a = input()

   w1, w2 = a.split()

   dict[w1] = w2

   dict[w2] = w1

print(dict[input()])

Explanation:

Intialize your dictionary.

Ask for how many keys you will be adding to the dictionary.

Over a for loop, take an input of keys and values and split them and add them to the dictionary.

I set the key as a value and a variable due to the fact that we are working with synonyms and if the user inputs a synonym that is only the value, we can't get another synonym out. Therefore it is better if we make each word a key and a value.

Then print a synonym of whatever the user inputs.

Other Questions
Genetic engineering involves _______ to achieve desired results. a. enzyme production b. modifying products and processes c. changing one organism into another d. introducing traits into organisms Please select the best answer from the choices provided A B C D Simplify 12x^7y^3 divided by 6x^3y A steel beam is rotated in a horizontal plane to provide the centripetal acceleration for training pilots. If the pilot sits 2.19 m from the center of rotation, at what speed must he rotate in order to experience a horizontal centripetal acceleration of 65.8 m/s/s? water flows from a faucet at a constant rate. Kian measures 8 cups of water in 6 second s. What is the constant proportionality for the relationship of cups of water to minutes Mrs. Smith gives a group of students with a list of five different transformations of Triangle 3 todraw as follows: 1. Transform Triangle 3 into Triangle 4 by rotating 90 counterclockwise around thepoint (1,1) Paula is the student council member responsible for planning an outdoor student dinner dance. Plans includehiring a band and buying and serving dinner. She wants to keep the ticket price as low as possible to encouragestudent attendance while still covering the cost of the band and the food.1.) Band A charges $700 to play for the evening and Band B charges $550 plus $1.50 per student.a. Write a system of equations to represent the costs of the two bands. Use y for total cost and use x fornumber of students. plez help last question What are advantages of taking daily measurements? A series of articles were written in order to persuade the states to ratify the constituionA. Articles of ConfederationB. Declaration of IndependenceC. Federalist PapersD. James Madison Choose the correct demonstrative adjective for the noun libros. A. EstaB. EsteC. Estas D. Estos which is equivalent to 2:3?1/24/612/1320/25 what is the opposite -2/5 a savings account earns 8% interest each year, compounded quarterly (4 times a year). If a person invests $100 and makes no further deposits or withdrawals, what is the balance in the account after 3 years? Ball A, moving towards the right, collides withstationary ball B. Ball A bounces back; B movesoff slowly to the right. Which has the greatermass, A or B? Can anyone help me please! Im not good at this Grammar/mehanics a good introduction paragraph will state all three of the main supporting details to an argurment PLEASE HELP! BRAINLIEST IF CORRECT!A certain crate can hold up to 1700 pounds when shipped. An item that weighs 110 pounds was placed in the box. If the variable "w" stands for the amount of additional weight the box can hold, which of the following units could apply to that variable?A. inchesB. metersC. gallonsD. pounds If you went to a storeand you paid 80% of theprice of a jacket, whatpercent was the jacketdiscounted? If two triangles are similar with a zoom factor of 3, and the smaller one has area 12 sq. units, what is the area of the bigger one? the answer is 108 sq units, im curious how it got there Insurance rates are lower for those with poor credit true or false