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]
3 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]3 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
What inventor patented the first American movie projector?
yulyashka [42]
Thomas edison is the answer
3 0
3 years ago
Read 2 more answers
✨Why is among us so addictive I try to play one game but end up playing over 20✨
lapo4ka [179]

Answer:

it is i got in troble for playing it so much lol

Explanation:

sorry for the spelling

5 0
3 years ago
Read 2 more answers
What does the National Institute of Standards and Technology do? Promotes innovation by advancing measurement standards promotes
cluponka [151]

Answer:

Promotes innovation by advancing measurement standards

Explanation:

The National Institute of Standards and Technology was Founded in the year 1901, this agency is a non-regulatory body that is found within the United States Department of Commerce.

The mission of this agency is the promotion of innovation and also industrial competitiveness through the advancing of measurement science, standards, and also technology in several ways that raises economic security and also brings about improvement in the quality of life.

4 0
3 years ago
Read 2 more answers
1)Write the command that moves the file data1 into the directory testdata:
mrs_skeptik [129]
1) mv data1 testdata/
2) mv data1 ../
3) ls letters

These are the *nix commands. You can find out more by looking at their man pages. You can get more info about the man subsystem by running: man man
8 0
3 years ago
Explain the nature of documents that can be suitable for merging
nadezda [96]
It can be a letter, stationery , or any types of template containing the information that you want to send to the vendor or to the customer.

the documents should contain special field codes that you insert which names and addresses reference will be replaced with the information from the data source
4 0
3 years ago
Other questions:
  • Match the job skills with the correct job role.
    12·1 answer
  • The help desk received a call from a user who cannot get any print jobs to print on the locally shared printer. While questionin
    10·2 answers
  • By Carl Sandburg
    6·1 answer
  • A distortion of information about the demand for a product as it passes from one entity to the next across the supply chain is c
    10·1 answer
  • _________________ ___________________ is an encrypted code that a person, website, or organization attaches to an electronic mes
    9·1 answer
  • Robert gets home from school at 3 p.M. His mom has to leave for her shift at work at 3:15 and she wants him to watch his baby br
    9·1 answer
  • What Fortnite skin is more og?
    5·2 answers
  • What is data science?​
    15·1 answer
  • Types of Hazards Mitigation Measures
    8·2 answers
  • Array bounds checking should be directly coded into a system rather than assumed.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!