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
s2008m [1.1K]
3 years ago
10

Write a fragment of code that reads in strings from standard input, until end-of-file and prints to standard output the largest

value. You may assume there is at least one value. (cascading/streaming logic, basic string processing)
Computers and Technology
1 answer:
Nady [450]3 years ago
8 0

Answer:

Explanation:

Sample input file: numbers.txt

8 9 7 67 78 45 67 99 1001

Sample Output:

The largest value is:1001

Code to Copy:

// include stdafx, if using visual studio.

#include "stdafx.h"

// declare the necessary header files.

#include <iostream>

#include <string>

#include <fstream>

using namespace std;

// Start the main function

int main()

{

// create the object of ifstream.

ifstream in_file;

// Open the file

in_file.open("numbers.txt");

// Declare the string variable

string str;

// Declare the integer variables.

int maximum = 0;

int num;

// Check whether the file open

if (in_file.is_open())

{

// Traverse the file till the end.

while (!in_file.eof())

{

// traversing the value.

in_file >> str;

// convert the string into integer.

num = stoi(str);

// Check whether value is max or not.

if (maximum < num)

{

// Update the value of maximum.

maximum = num;

}

}

}

// Display the statement on console.

cout << "The largest value is:" << maximum << endl;

// Close the file.

in_file.close();

system("pause");

return 0;

}

You might be interested in
In Criminal justice, the type of evidence which contradicts a given theory is known as?​
irina [24]

Answer:

In general, scientific evidence are the results of scientific tests used to prove or disprove a theory or hypothesis. In criminal cases, scientific evidence is used to help jurors understand and determine the facts of a case. Explanation:

3 0
3 years ago
The Leal button is located in the
Fed [463]
The button is located on the left side of the gear shift right under the main shift button
7 0
3 years ago
Which of these agents of education empowers the other..........
Tomtit [17]

Answer:

B. school

Explanation:

Because the school is where you learn and gain knowledge

4 0
2 years ago
Read 2 more answers
In the Northern Hemisphere, large south-facing windows receive more total sunlight during the day and would be a part of a ___ s
9966 [12]

Answer:

Passive solar heating system

Explanation:

The goal of passive solar heating systems usually refers to the system in which the energy provided by the sun is used for heating and cooling of the living places in a house.

When sunlight falls on the house, the building elements capture the heat energy of the sun and it later releases back this heat when the sun is not there. The main objective of this system is to regulate the room temperature. It is comprised of two main elements, one is the glasses that face towards the south and a thermal mass that is used for heat absorption, storing and distribution of heat.

6 0
3 years ago
What cold, hard facts support your position?
Sladkaya [172]
Idk what is it?
a computer?
plz mark me as brainliest
6 0
3 years ago
Other questions:
  • Rewrite this method so that it avoids the use of a return statement:
    15·1 answer
  • Array A is not a heap. Clearly explain why does above tree not a heap? b) Using build heap procedure discussed in the class, con
    15·1 answer
  • Which of these automotive repair areas helps the vehicle change speeds to operate efficiently under all conditions?
    5·1 answer
  • What is the 7 X 7 when referring to PowerPoint presentations?
    12·2 answers
  • What is the difference between primary storage,secondary storage and offline storage what type of storage can be
    6·2 answers
  • What is ambiguous grammar, explain in maximum 50words.
    5·1 answer
  • Which is the oldest of the following sports?
    6·2 answers
  • What is the purpose of a forecast worksheet?
    15·1 answer
  • What is the role of computer in education sector?​
    13·1 answer
  • ANSWER QUICKLY!!! <br><br> What is an advantage of digital portfolios?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!