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
Help!!!!!!!!!!!!!!!!!!!
ExtremeBDS [4]
Column if the answer.
6 0
3 years ago
To enforce the concept of separating class definition from its function implementations, where should the function implementatio
zzz [600]
D(in a .c file ) because that is where it should be placed :)
4 0
2 years ago
What are the possible sources of the information that defines the functional dependencies that hold among the attributes of a re
valkas [14]

A functional dependency describes a relationship between the attributes of an entity such that the value of one attribute is dependent on the value of some other attribute and is very well affected by it.

There can be various sources of information that define functional dependency. For instance, an attribute age can define the functional dependency with the attribute ID. One cannot include the voter ID if they are not above 18 years of age.

Similarly, the attribute date of joining can define the functional dependency with the attribute experience, as the experience in a particular organization can be calculated by subtracting the joining date fro the current date.

3 0
3 years ago
Write common ICT tools​
Naddika [18.5K]
  • computers
  • laptops
  • printers
  • scanners
  • software programs
  • data projectors
  • and interactive teaching box.

4 0
2 years ago
Uses of the following button in a keyboard: Prt SC, Home, Shift, Tab, Pg Up.​
creativ13 [48]

Answer:

This Print Screen key is used to take the screenshots of all that is appearing on the screen, and this can then be pasted in paint and saved in some location of the computer.

The Home key takes the cursor from the current position to the top left, or the start of the file.

Shift: There are two shift keys. And they are used to print the character in the capital. And when the caps lock is busy it can be used to print in lower case. It is also used together with arrow keys to select a part of the text.

Tab: This key moves the cursor from the current location to the location which we know as tab stops ( and the very next one).

Pg Up:​ The page up is being used for scrolling up, and the distance to which limit the scrolling will take place depends upon the application you are working on.

Explanation:

Please check the answer.

4 0
3 years ago
Other questions:
  • Demonstrate your grasp of the Unix file system by constructing a directory structure as follows: In your home ( ~ ) directory, c
    11·1 answer
  • Does anybody know how to use these showers?
    11·2 answers
  • Jane is debugging a code consisting of 25 lines. The code starts executing at line 11. At line 13, the code calls another method
    10·2 answers
  • After you enter the details for the first selected recipient in the New Address List dialog box, click _______ to add another re
    9·1 answer
  • What is the best brand of folders
    13·2 answers
  • Can you please help me with the AP Computer Science Fill in the blank. What goes on number 5 8 and 18. I don’t understand this I
    8·1 answer
  • There are many commercially made household linens found in the?
    7·1 answer
  • Which of these are characteristics of a Python data type? Check all that apply.
    11·1 answer
  • An employee of a large corporation remotely logs into the company using the appropriate username and password. The employee is a
    10·1 answer
  • Task 2
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!