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
Which spreadsheet feature could the scholarship committee use to locate applicants who meet the criteria?
Radda [10]

Answer:

H8

Explanation:

4 0
2 years ago
The fundamental difference between a switch and a router is that a switch belongs only to its local network and a router belongs
Alla [95]

Answer:

The answer is True

Explanation:

Switches are responsible for connecting computers within a network and it belongs only to its local network. Its responsibility is to filter and forward packets between LAN segments. They operate on layer two (2) and sometime layer three (3) of the OSI Model.

Routers on the other hand, are responsible for the interconnections of two or more networks. They forward data packets between networks. They reside at gateways, exactly where two or more networks connects. And they use communication protocols to effectively and efficiently communicate among two or more host.

7 0
2 years ago
To insert a new slide, which tab option should you select?
jek_recluse [69]

Ithink that the answer is C)

4 0
2 years ago
Read 2 more answers
Which is NOT a way the network operating sys-
irakobra [83]

Answer: A user authentication

3 0
3 years ago
Create a new data frame, first_south, by subsetting titanic to include instances where a passenger is in the first class cabin (
Virty [35]

The data frame first_south is created using first_south = (titanic['Pclass']==1) & (titanic['Embarked']=='S')

<h3>How to create the data frame?</h3>

To do this, we make the following assumptions:

  • The pandas module has been loaded as pd
  • The dataset has also been loaded as titanic

When pclass column is 1.

This is represented as:

titanic['pclass']==1

When the passenger boards from Southampton.

This is represented as:

titanic['Embarked']=='S'

So, we have:

first_south = (titanic['Pclass']==1) & (titanic['Embarked']=='S')

Read more about data frames at:

brainly.com/question/16524297

#SPJ1

4 0
1 year ago
Other questions:
  • Your computer is configured to obtain an ipv4 address and dns server address automatically. what utility will help you to find t
    7·1 answer
  • People with healthy media diets:
    12·1 answer
  • Hacker is a person who illegally breaks into a system or network without any authorization to destroy, steal sensitive data or t
    14·1 answer
  • _____ provides vital protection and maintenance services for system hardware and software, including enterprise computing system
    12·1 answer
  • What are attribute grammars used for?
    8·1 answer
  • What will be the output of the following code? &lt;?php $foo = 'Bob'; $bar = $foo; $bar = "My name is $bar"; print $bar; print $
    8·2 answers
  • A recursive method that computes the number of groups of k out of n things has the precondition that ______. n is a positive num
    12·1 answer
  • Mississippi law codes state that bullying and cyberbullying are against the law. A court can decide to incur ___________________
    10·1 answer
  • If a machine cycle is 2 nanoseconds , how many machine cycles occur each second?
    7·1 answer
  • 1k bits equals to how many bits
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!