answer.
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]
2 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]2 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
You would use the _______ conditional formatting options when analyzing a worksheet in which you want to highlight the highest o
nirvana33 [79]

Answer:

Top/bottom conditional formatting

Explanation:

The top/bottom conditional formatting automatically carries out the task of finding the highest, lowest and even average values.

Conditional formatting formatting gives one the opportunity to enhance reports and dashboards as they work on excel.

You use the too/bottom formatting to highlight cells whose values of highest in a dataset and lowest in a dataset

4 0
1 year ago
how do you make a circuit so 1 switch will turn on/off all the lights(3 lights) and a second switch will change the lights from
expeople1 [14]

Parallel circuit. On a wire you put the lights and one switch, on the other you put a resistor and another switch. (and the third wire contains the generator)
7 0
1 year ago
Read 2 more answers
What elements of SANS 20 you could leverage to reduce the TCP/IP vulnerabilities of your workstation
Vlada [557]

Answer:

- limitation and control of network ports, protocols and services.

- Continuous vulnerability assessment and remediation.

Explanation:

The TCP or transmission control protocol is a layer 4 protocol (transport), that reliably transports packets in sequential segments to an application in the destination computer, using the ip address and the port number of the application.

The ICMP sent during the TCP/ip activities, can render the network vulnerable to attacks. limitation and control of the network ports, protocols and services and continuous assessment would mitigate the vulnerability of the TCP/ip model.

5 0
1 year ago
Suppose your name was George Gershwin. Write a complete program that would print your last name, followed by a comma, followed b
NNADVOKAT [17]

Answer:

I will write the code in C++ and JAVA      

Explanation:

<h2>JAVA CODE</h2>

public class Main

{ public static void main(String[] args) {

       // displays Gershwin,George

     System.out.println("Gershwin,George"); }  }

<h2>C++ Code:</h2>

#include <iostream>

using namespace std;  

int main()

{  cout<<"Gershwin,George"; }    

// displays last name Gershwin followed by , followed by first name George

//displays Gershwin,George as output.

6 0
2 years ago
Read 2 more answers
You have been tasked with building a URL file validator for a web crawler. A web crawler is an application that fetches a web pa
mixas84 [53]

Answer:

Python Code:

def validate_url(url):

#Creating the list of valid protocols and file name extensions

valid_protocols = ['http', 'https', 'ftp']

valid_fileinfo = ['.html', '.csv', '.docx']

#splitting the url into two parts

url_split = url.split('://')

isProtocolValid = False

isFileValid = False

#iterating over the valid protocols and file names for validity

for x in valid_protocols:

if x in url_split[0]:

isProtocolValid = True

break

for x in valid_fileinfo:

if x in url_split[1]:

isFileValid = True

break

#Returning the result if the URL has both valid protocol and file extension

return (isProtocolValid and isFileValid)

url = input("Enter an URL: ")

print(validate_url(url))

Explanation:

The image of the output code is attached. Hope it helps.

4 0
1 year ago
Other questions:
  • What is one effective way for employees to keep their skillsets current?
    8·2 answers
  • Column, bar, pie, line, and scatter are all types of_____
    9·1 answer
  • . Write a recursive function names factorial to compute the factorial of the parameter. Also write the main function, where you
    15·1 answer
  • Address the FIXME comments. Move the respective code from the while-loop to the created function. The add_grade function has alr
    14·1 answer
  • Write a method that takes three numerical String values and sums their values.
    14·2 answers
  • You are modeling a small part of an online flight reservation system, according to the following description. A flight is a sing
    11·1 answer
  • How many times is the function wordScramble() called in the given program? public class WordScramble { public static void wordSc
    6·1 answer
  • Return 1 if ptr points to an element within the specified intArray, 0 otherwise.
    7·1 answer
  • Write a SELECT statement that selects all of the columns for the catalog view that returns information about foreign keys. How m
    6·1 answer
  • Calvin is an aspiring graphic designer. He wants to achieve Adobe Certified Expert certification in software that will be helpfu
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!