Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7445995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T12:11:26+00:00 2026-05-29T12:11:26+00:00

I am trying to write simple program using ONLY for loop ( if then

  • 0

I am trying to write simple program using ONLY for loop (if then statement is allowed i think) And I am having trouble getting the highest snow date “calculated” from a bunch of user inputs.

This program writes user input amount of snow that fell on a number of days to a text file. I am supposed to also list the highest snow amount that fell, but don’t (?) know how to do it in the for loop.

for (dayNumber = 1; dayNumber <= numOfSnowDays; dayNumber++)
    {   
        mostSnowDay = dayNumber;
        cout << "Day number:  " << dayNumber << endl;
        cout << "Enter amount of snow: " << endl;
        cin >> amtOfSnow;
        totalSnow = totalSnow + amtOfSnow;
        outFile << setfill(' ') << setw(15) << dayNumber << setw(25) << setprecision(2)   << amtOfSnow << endl;

        if ( dayNumber == 1 )
        {
            mostSnowDay = dayNumber;                             
        }
        else if ( amtOfSnow < mostSnowDay )
        { 
              //dont know what to put here or even if this is right. 
        }

    };
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T12:11:27+00:00Added an answer on May 29, 2026 at 12:11 pm

    You need some extra variables there:

     if ( dayNumber == 1 )
     {
         mostSnowDay = dayNumber;   // default - most amount of snow in first day  
         mostAmtOfSnow = amtOfSnow; // 
     }
     else if ( amtOfSnow > mostAmtOfSnow ) //if subsequent day has more snow
     { 
         mostSnowDay = dayNumber;     //mark the day
         mostAmtOfSnow = amtOfSnow;   //change largest amount of snow
     }
    

    EDIT: Credit to Dan F. Remove the mostSnowDay = dayNumber; instruction at the beginning of the loop, it will re-initialize your variable each time the loop enters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write a simple program using WinSnmp in C++. There is very
I trying to use OpenCL using HASKELL. I write a simple program converting a
I'm trying to write a simple program to encrypt and decrypt files using the
I'm trying to write a simple program to change my desktop wallpaper. I'm using
I'm trying to write a simple program in VC++ which will just initialize the
I am trying to write a simple program to open a socket channel to
I'm just starting out writing trying to write a simple program in C and
I'm trying to write a simple curl program to retrieve the web page in
I'm trying to write a very simple program, I want to print out the
I'm trying to write a simple stock check program, and I have a Table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.