1answer.
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
dlinn [17]
2 years ago
9

Write a program that prints the U.S. presidential election years from 1792 to present day, knowing that such elections occur eve

ry 4 years.
Computers and Technology
1 answer:
miv72 [106K]2 years ago
4 0

Answer:

The cpp program to print US presidential years is given.

#include <iostream>

using namespace std;

int main()

{

   // variable to hold presidential election year declared  

   int elec_year;

// variable to hold presidential election year initialized to 1792  

elec_year=1792;

   

// the value displayed on the console output

   std::cout << "The U.S. presidential election years from 1792 to present day are listed. " << std::endl;

   

   // loop executes till year is less than or equals 2020

   do

   {

       // initial value is printed

       std::cout << elec_year << std::endl;

       

       // value is incremented by 4

       elec_year = elec_year + 4;

       

   }while(elec_year<=2020);

   return 0;

}

OUTPUT

The U.S. presidential election years from 1792 to present day are listed.  

1792

1796

1800

1804

1808

1812

1816

1820

1824

1828

1832

1836

1840

1844

1848

1852

1856

1860

1864

1868

1872

1876

1880

1884

1888

1892

1896

1900

1904

1908

1912

1916

1920

1924

1928

1932

1936

1940

1944

1948

1952

1956

1960

1964

1968

1972

1976

1980

1984

1988

1992

1996

2000

2004

2008

2012

2016

2020

Explanation:

The program works as described.

1. An integer variable, elec_year, is declared and initialized with the first US presidential year value, 1792.

2. Inside the do-while loop, the variable, elec_year, is first printed to the console followed by a new line inserted using, endl.

3. The variable, elec_year, is then incremented by 4.

4. The do-while loop continues till the value of the variable, elec_year, does not exceeds the current year, 2020.

5. The program ends with a return statement since main() has return type int.

6. Only one variable is used in the program.

7. The program consists of only main() method since cpp is not completely object oriented programming language.

8. The same program, if written in object oriented programming language like java or c# will be written inside a class and executed through main() method.

You might be interested in
Based on current and upcoming gaming technologies, what changes do you expect to see in the next generation of gaming consoles?
damaskus [11]
Better graphics getting 1080 p easily running on 240 frames and a higher storage so then you could have more games on the console
4 0
3 years ago
Into which of these files would you paste copied information to create an integrated document? A. Mailing list B. Source C. Data
viva [34]

it would be b.mailing list


5 0
3 years ago
Read 2 more answers
What elements are needed in a workstation domain policy regarding use of antivirus and malicious software prevention tools?
Reika [66]
The server should be able to block unauthorized access, a good firewall but still, enable those authorized to have an access. However, there should be security on vulnerable parts of the system that may lead to corruption and easy access to data thieves.
3 0
2 years ago
Discuss Hardware is useless without software?​
Alexus [3.1K]

Explanation:

Hardware is useless without software because the machinery will not and cannot do anything without programming to tell it what to do. Without an operating system, the computer can't do anything. Without other software, like Microsoft Office, you can't type anything or listen to music or watch video or anything

7 0
2 years ago
Difference between server and a client computer
maw [93]

Answer:

A server stores data for a client computer to access and use, and pretty self eplanitory for a client computer

Explanation:

5 0
2 years ago
Other questions:
  • The "fathers of the Internet" are Vinton Cerf and ________. Select one: A. Robert Kahn B. Robert Cailliau C. Tim Berners-Lee D.
    11·1 answer
  • Victoria enjoys laughing with her friends as they walk around the track after school. Which best describes her hate rate during
    5·1 answer
  • What does utp stand for?
    11·2 answers
  • Which best explains what a credit score represents
    10·2 answers
  • A snail goes up A feet during the day and falls B feet at night. How long does it take him to go up H feet? Given three integer
    8·1 answer
  • Describe the functions of ALU, resisters, CU, BIU, Cache and FPU.
    7·1 answer
  • Presses the Schedulr app icon Selects the list item for CSCI 448 Presses the "View Classroom on Map" button While only performin
    11·1 answer
  • Select four tasks associated with operating system maintenance. Cleaning inside the computer Defragmenting the hard drive Deleti
    11·1 answer
  • Write a C++ Programm in which inheritance is used
    7·1 answer
  • How do I create a powershell script to make a Windows user account that is a non-admin user
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!