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
Modify your main.c file so that it allocates a two dimensional array of integers so that the array has 20 rows of 30 integers in
Alexandra [31]

Answer:

Explanation:

b

7 0
3 years ago
5(x + 4) = 4(x -6) |<br><br><br>How to do this problem
vichka [17]
5 ( x + 4 ) = 4 ( x - 6)
5x + 20 = 4x - 24
5x -4x + 20= 4x - 4x - 24
1x + 20 = -24
1x + 20 - 20 = -24 - 20
1x = -44

check

5 (-44 + 4) = 4 ( -44 - 6)
5 (-40) = 4 (-50)
-200 = -200
3 0
3 years ago
Power point 2016 which chart element provides the boundaries of the graphic?
SVEN [57.7K]
D. (chart elemments) - correct answer
8 0
4 years ago
Name the two types of control systems.<br> PLEASE HELP THIS WAS DUE HOURS AGOOOO
vodomira [7]

Answer:

Open loop control systems.

Closed loop control systems.

Explanation:

5 0
3 years ago
Read 2 more answers
Which of the following actions should you take when turning left at an intersection?
fomenos
The answer is B Okay good luck and dont...mess it up
8 0
4 years ago
Other questions:
  • Codio Challenge Activity PythonWe are passing in a list of numbers. You need to create 2 new lists in your chart, then put all o
    13·1 answer
  • What is the binding time for the following in C/C++ program. Explain. a. The location of memory of a local variable in a functio
    9·1 answer
  • wHAT ARE THE 5 LAYERS in the internet protocol stack andwhat are the principal responsibilities of eack of theselayers.?
    12·1 answer
  • Whats the difference between copying a file to my desktop and creating a shortcut?
    8·1 answer
  • An organization uses SAP financial management software to store accounting details and Microsoft CRM software to record customer
    12·1 answer
  • Which of the following Internet protocols is MOST important in reassembling packets and requesting missing packets to form compl
    11·1 answer
  • Choose two browsers and compare their security features.
    5·1 answer
  • It is unlawful in the State of Florida for any person, ______________________, to be a passenger in the front seat of a motor ve
    7·1 answer
  • Which of the following is an input device on a toaster?
    10·2 answers
  • Pls help now the question is very hard someone help me pls​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!