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
Ile 1 cm<br> ?<br> 50 m<br> The an
otez555 [7]

Answer:

Could you post the full question please

Explanation:

3 0
4 years ago
Read 2 more answers
When a program lets the user know that an invalid menu choice has been made, this is an example of?
kolezko [41]

The question has the multiple choices below

A) Input validation
B) output correction
C) compiler criticism
D) output validation

The answer is (A) Input validation

Also known as data validation, it is the correct and proper testing of any input supplied by an application or a user. It prevents wrongly formed data from entering the system. Applications should be able to check and validate every input entered into the system since it is hard to detect a malicious user trying to gain entry into software.










5 0
3 years ago
Hyper-v enables windows server 2008 to operate as a _____ server.
lianna [129]
 Answer: Virtual                                                                                                     <span>Hyper-V enables Windows Server 2008 to operate as a virtual server.</span>
3 0
3 years ago
What is RAM? explain it
Zina [86]
RAM is memory in the computer
3 0
3 years ago
Read 2 more answers
ZyDE 1.4.2: Fixing syntax errors.
skad [1K]

Using the knowledge of computational language in JAVA it is possible to write a code that Fixing syntax errors Click run to compile, and note the long error list.

<h3>Writting the code:</h3>

<em>public class BeansInJars {</em>

<em>    public static void main(String[] args) {</em>

<em>        int numBeans;</em>

<em>        int numJars;</em>

<em>        int totalBeans;</em>

<em>        numBeans = 500;</em>

<em>        numJars = 3;</em>

<em>        System.out.print(numBeans + " beans in ");</em>

<em>        System.out.print(numJars + " jars yields ");</em>

<em>        totalBeans = numBeans * numJars;</em>

<em>        System.out.println(totalBeans + " total");</em>

<em>    }</em>

<em>}</em>

See more about JAVA at brainly.com/question/12975450

#SPJ1

5 0
2 years ago
Other questions:
  • Sam wants to move across the text in his documents to add data at predefined stops. Which key will he use to navigate through th
    13·2 answers
  • Which of the following is a true statement about psychological tests administered by computers? computers make standardization e
    9·1 answer
  • The software application associated with a specific file type is called a(n) __________ application.
    12·1 answer
  • To be a successful computer systems engineer, you must be proficient in programming languages and operating systems. Similarly,
    5·2 answers
  • What is different between attaching a file on an email program versus a smartphone?
    12·2 answers
  • HI PLZ HELP 11 POINTS!!!
    12·2 answers
  • Any one have a snnaap chhhaatt if so i need help with something n there
    15·2 answers
  • Write a program in which you input three numbers they canhave decimals so float values and the program gives you the minvalue ou
    8·1 answer
  • Please please help ASAP it’s timed
    13·1 answer
  • Digital rights include the right to
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!