Print US Presidential Election Years Since 1792

  • Context: C/C++ 
  • Thread starter Thread starter ineedhelpnow
  • Start date Start date
  • Tags Tags
    Years
Click For Summary

Discussion Overview

The discussion revolves around modifying a C++ program to print U.S. presidential election years from 1792 to the present, focusing on the implementation of a while loop to achieve this. Participants express varying levels of understanding and engagement with the programming task.

Discussion Character

  • Homework-related
  • Technical explanation
  • Conceptual clarification
  • Debate/contested

Main Points Raised

  • One participant requests help in modifying a C++ program to print election years, emphasizing the need to use a while loop with a less than or equal to condition.
  • Another participant questions the original poster's engagement with the problem, suggesting they should attempt to implement the code themselves before seeking help.
  • A participant acknowledges their struggle to understand recent lessons, indicating that they find the material confusing and that their questions are not strictly homework-related.
  • In response to the previous comments, another participant defends the original poster, suggesting that learning programming can be challenging and that support is important.
  • One participant proposes a thought experiment, asking the original poster to manually write out election years up to 1815 and reflect on the steps involved in the process, including addition and comparison.

Areas of Agreement / Disagreement

There is no clear consensus among participants. Some emphasize the importance of attempting the problem independently, while others advocate for providing support and understanding during the learning process. The discussion reflects differing perspectives on how to approach learning programming.

Contextual Notes

Participants express varying levels of familiarity with C++ and the specific programming concepts involved, indicating a range of understanding and experience with the material.

ineedhelpnow
Messages
649
Reaction score
0
Modify the program to print the U.S. presidential election years since 1792 to present day, knowing such elections occur every 4 years. Don't forget to use <= rather than == to help avoid an infinite loop.

Code:
#include <iostream>
using namespace std;

int main() {
   int electYear = 0; 
   
   electYear = 1792;
   // FIXME: Put the following in a while loop 
   cout << electYear << endl;

   return 0; 
}

how do i do this?
 
Technology news on Phys.org
ineedhelpnow said:
Modify the program to print the U.S. presidential election years since 1792 to present day, knowing such elections occur every 4 years. Don't forget to use <= rather than == to help avoid an infinite loop.

Code:
#include <iostream>
using namespace std;

int main() {
   int electYear = 0; 
   
   electYear = 1792;
   // FIXME: Put the following in a while loop 
   cout << electYear << endl;

   return 0; 
}

how do i do this?

Do.. do you have any thoughts on the matter at all? I'm asking because most if not all of your C++ questions lately have been of the form "here is some code, how do I implement this". You need to at least give it a try.
 
i know. i have been trying to understand. but these last lessons we've been going over make no sense to me. I am trying to understand but its all fuzzy. most of the ones I've been posting lately also arent homework problems. they are just activities.
 
Bacterius said:
Do.. do you have any thoughts on the matter at all? I'm asking because most if not all of your C++ questions lately have been of the form "here is some code, how do I implement this". You need to at least give it a try.

She is clearly giving it a try, don't be so hard on her, I'm sure you also encountered issues when learning C++ and had people there to help out.
 
ineedhelpnow, imagine that it's now 1815 instead of 2015. Could you do manually what you need the program to do, i.e., write election years until 1815? While doing it, think carefully about what steps you are performing. Are you adding numbers? Are you comparing them? How do you know it's time to stop? Can you do this if you have only limited space to write numbers on paper, but you can erase old numbers and write new ones in the same space?

After you do this, try to describe the sequence of steps you had to perform and post this description.
 

Similar threads

Replies
12
Views
3K
  • · Replies 15 ·
Replies
15
Views
4K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 2 ·
Replies
2
Views
9K
  • · Replies 22 ·
Replies
22
Views
4K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 1 ·
Replies
1
Views
2K