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
Abby wants to simply share a snapshot of her calendar with another user. Which option should she choose to achieve this
Papessa [141]

Answer:

Screenshot

Explanation:

Just a guess

8 0
3 years ago
Read 2 more answers
5 programas más utilizados para realizar presentaciones electrónicas
Alchen [17]

Answer:

Google Slides

Microsoft PowerPoint

Visme

Prezi

Slidebean

3 0
2 years ago
The computer stores a program while the program is running, as well as the data thatthe program is working with, in __________.
Elena-2011 [213]
<span>While you are working with a document using a program such as wordpad, the document is stored in .exe file</span>
3 0
3 years ago
Brian’s father drives a car that uses voice commands for navigation. Which AI application field is Brian’s father using?
sergeinik [125]

Answer:

Linguistics.

Explanation:

It is  the scientific study of language and its structure, including the study of morphology, syntax, phonetics, and semantics. Specific branches of linguistics include sociolinguistics, dialectology, psycholinguistics, computational linguistics, historical-comparative linguistics, and applied linguistics.

Please mark as Brainliest! :)

6 0
2 years ago
How many times will an infinite loop repeat?
ExtremeBDS [4]

Answer:

The infinite loop is suppose to go on and on it never ends. My best guess is the third one.

7 0
2 years ago
Other questions:
  • Sometimes data you export from Access needs to be formatted as a text file instead of an Excel file.
    14·1 answer
  • Help me match these answers
    5·1 answer
  • Using the Vigenere cipher, does the length of the key matter?
    8·1 answer
  • Most hand sewing begins and ends with
    5·1 answer
  • Pls help I will give lots of points
    9·1 answer
  • 1. Distinguish between
    7·1 answer
  • Anyone has any ideas for a gaming setup i can buy for christmas. Something with high framing rates (monitor included) for about
    15·1 answer
  • Laptops are used for accessing the internet. Name two advantages and two disadvantages for using a laptop rather than a smartpho
    5·2 answers
  • Which type of mic is durable, versatile and does not rely on power?
    14·2 answers
  • Is jesus dead or alive
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!