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
Can someone please give me Python test 3 it would help me tremendously
Ket [755]

Question 1:  To tell what will happen when an if-statement is false.

Question 2: The = should be ==

                    elseif should be elif

                    The else should have a :

Question 3: All algorithms can only do number calculations.  

Question 4: and

Question 5: To make a follow-up True/ False decision

Question 6: if (text1 > 15):

Question 7: if (text1 == 78):

Question 8: if (num1 != num2):

Question 9: >=

Question 10: 4

Question 11: 3

Question 18: a < b and a != b  

Question 19: !=

Sorry about 12 - 17 and 20 i can't seem to find those questions guessing you wanted edhesive. I dont have an account on it.

5 0
3 years ago
.Write a program that reads in the length and width of a rectangular yard (in meters) and the length and width of a rectangular
nata0808 [166]
What is the language you want for the code?
3 0
3 years ago
The process that uses 3D modeling software to create a representation of a three dimensional object is called 3D modeling.
MissTica
This statement is (True)
5 0
3 years ago
Read 2 more answers
Shelly recorded an audio composition for her presentation. Arrange the following steps that Shelly followed in the proper order.
Dimas [21]

Answer:

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

Explanation:

Shelly recorded an audio composition for her presentation. She needs to follow the following proper orders to get composition done for her presentation.

  1. She connected her microphone to her computer.
  2. She selected the record option in her DAW.
  3. She added effects to her audio composition.
  4. She saved the audio composition in an appropriate file format.
  5. She saved her audio composition on an optical drive.
3 0
3 years ago
a key part of staying safe is employing good habits. drag the step number to the proper sequence triple a
solong [7]

Answer:

where are the step number. I can't find any

6 0
3 years ago
Other questions:
  • By default, only the ________ options are allowed when the worksheet is protected.
    11·1 answer
  • Which of the following is a good choice to help you stay organized when you are away from the office? A. Personal Information ma
    7·1 answer
  • Which Windows feature captures and stores copies of folders and files at specific points in time, allowing users or administrato
    10·1 answer
  • Can you please help me at question two
    13·1 answer
  • What does an operating system do?
    11·2 answers
  • A cell reference with only one dollar sign before either the column or the row is called an absolute reference.
    10·1 answer
  • Select the correct answer.
    6·2 answers
  • Necessary component of creativity
    11·1 answer
  • How can computational thinking techniques be applied to software development
    6·1 answer
  • Why must a satellite have distinct uplink and downlink frequencies.​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!