Write a program with a loop that lets the user enter a series of integers. the user should enter -99 to signal the end of the series. after all the numbers have been entered, the program should display the largest and smallest numbers entered.

Your program should get the integers from a file and not from the console. You can assume that all numbers are positive or 0 and that there exists at least one number in the file (other than -99). You can also assume that there is a -99 at the end of the file. This signifies the end of the file and is not apart of the input data (it will not be the least number). You do not need to output anything to this file. You should name your file input file "Numbers.txt". You need to use a loop in order to input the numbers of the file. Your program should work for any number of numbers inside of Numbers.txt.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

int main(int argc, char** argv) {

    ifstream input;"Numbers.txt",ios::in);
    int greatest,least;
    greatest = -1;
    least = INT_MAX;
    int tmp;
    if (input.is_open()) {
       //there exists at least one number in the file (other than -99)
       while (input>>tmp) {// read every number in the file
            if (tmp == -99) {...
$10.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats