C/C++ Print US Presidential Election Years Since 1792

  • Thread starter Thread starter ineedhelpnow
  • Start date Start date
  • Tags Tags
    Years
AI Thread Summary
The discussion focuses on modifying a C++ program to print U.S. presidential election years from 1792 to the present, emphasizing the need for a while loop and the use of "<=" to prevent infinite loops. Participants express frustration over a lack of effort in understanding the code, urging the original poster to attempt the task independently. Suggestions are made to manually write out the election years to better grasp the logic of the program, encouraging a step-by-step breakdown of the process. The conversation highlights the importance of engaging with the material and developing problem-solving skills in programming.
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.
 
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...
Thread 'Star maps using Blender'
Blender just recently dropped a new version, 4.5(with 5.0 on the horizon), and within it was a new feature for which I immediately thought of a use for. The new feature was a .csv importer for Geometry nodes. Geometry nodes are a method of modelling that uses a node tree to create 3D models which offers more flexibility than straight modeling does. The .csv importer node allows you to bring in a .csv file and use the data in it to control aspects of your model. So for example, if you...

Similar threads

Replies
5
Views
3K
Replies
22
Views
3K
Replies
3
Views
3K
Replies
13
Views
2K
Replies
4
Views
3K
Replies
1
Views
1K
Back
Top