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
What file name would allow you to easily find and edit your document later in Word Online?
Fynjy0 [20]

Answer:

Essay 1_24_20 DRAFT

Explanation: I did the assignment and my answer was correct

5 0
3 years ago
Read 2 more answers
Karlie wants to eat a good breakfast before taking a test
babymother [125]
Yum sounds like a good idea
7 0
4 years ago
Read 2 more answers
You can declare new classes as needed; this is one reason java is known as a(n) ________ language.
____ [38]
You can declare new classes as needed : this is one reason java is known as a extensible language.
8 0
3 years ago
Read 2 more answers
Which of the following us considered to be intellectual property? Picturez or images on the internet, books, computers. Ortennis
klasskru [66]
Intellectual property is anything that has been designed, technically all of the above is a form of intellectual property. If only one answer is possible, I believe the best choice is images on the internet.

Speaking for the rest however, literary work is created and therefore the book is as well. Computers are designed so the specifications and design plans are also intellectual property. Same goes for the shoes
4 0
3 years ago
Why is computer called information processing machine....?​
mixer [17]

Answer:

Since the computer accepts raw data as input and converts into information by means of data processing

Explanation:

helping!!!

3 0
2 years ago
Read 2 more answers
Other questions:
  • Which device in a wireless local area network (wlan) determines the next network point to which a packet should be forwarded tow
    12·1 answer
  • In a circular linked list the last node points to the____ node.
    5·1 answer
  • A summer camp offers a morning session and an afternoon session.
    5·1 answer
  • ENG103 DISCUSSION BOARD 5
    12·1 answer
  • What are the first steps in creating a business document
    6·2 answers
  • Why do you think it is important to consider ethical considerations when reviewing technology and assessing the impact of partic
    9·1 answer
  • Many websites (mostly online shopping sites), monitor a person’s Internet browsing behavior, such as the websites we often visit
    14·1 answer
  • Complete the AscendingAndDescending application so that it asks a user to enter three integers. Display them in ascending and de
    7·1 answer
  • Trade Periodicals are usually highly scholarly resources<br> True<br><br> False
    5·1 answer
  • Astrid’s computer screen suddenly says that all files are now locked until money is transferred to a specific account, at which
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!