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
Given three packets of size 2,500 Bytes (caution this is Bytes not bits) each are ready inside computer 1 to be transmitted onto
gizmo_the_mogwai [7]

Answer: umm sorry

Explanation:

5 0
3 years ago
!!!!!16 POINTS!!!!Can a computer evaluate an expression to something between true and false? Can you write an expression to deal
levacccp [35]

Answer:

Yes a computer can evaluate between a true or false. x < 1, and if the condition is met, the value is true, else its false. A computer itself cannot handle any "maybe" expression, but with the influence of human opinion, in theory its possible. Chocolate cake < Vanilla cake, is an example. Entirely on opinion.

4 0
3 years ago
Consider an application that transmits data at a steady rate (for example, the sender generates an N-bit unit of data every k ti
grin007 [14]

Answer:

a; circuit-switched network.

b; No, it does not need congestion control.

Explanation:

For A;

A circuit-switched network is a better option for this application. This is because of the fact that the application is made up of long sessions with smooth data transfer capacity needs.

The transmission rate is known, and does not transmit in short intervals(short signals), every application session can have a bandwidth reserved without significant bandwidth wastage.

Also, the overhead expenses of setting up and tearing down connections are canceled out over the extensive period of running an application session.

For B;

If the packet-switched network is used, and traffic in the network comes from the said application. Even if every applications transmit one or more network connections. Still, we already know that every connection has enough transmission capacity to handle majority of the application data rates, no congestion(insignificant queuing) will happen.

This goes to say that no congestion control will be needed given such broad-based connection.

7 0
3 years ago
What do you remember about the difference between Canadian and US dollar (which one is greater)? Also, explain which online tool
Talja [164]
I’m not sure about USD but Canadian dollars are greater, one dollar CAD is equal to $0.79 US. So $10 CAD is equal to $7.90 US.
8 0
3 years ago
Which command compiles the Java source code file Welcome.java?
GarryVolchara [31]

Answer:

javac Welcome.java

Explanation:

In order to the file to compile with the default compiler in the JDK, the instruction must be of the form:

javac filename

(Note: the filename with the .java extension)

3 0
3 years ago
Other questions:
  • • The length of time between water level measurements/ control adjustments is DT. • If the water level drops to the bottom of th
    13·1 answer
  • Your company has a wireless network for its small office network. The wireless network does not broadcast its service set identi
    11·1 answer
  • Fred wants to analyze his spending habits of the past few years and has gathered information on the checks he has written from 2
    6·1 answer
  • 29 POINTS!!!
    6·1 answer
  • Write a program to complete the task given below: Ask the user to enter any 2 numbers in between 1-10 and add both of them to an
    8·1 answer
  • Plsss help anyone PLSSSSS ​
    13·1 answer
  • The term Linux Intrusion Detection System ( LIDS) refers to a command that allows an administrator to run processes as root with
    5·1 answer
  • When looking at security standard and compliance, which three (3) are characteristics of best practices, baselines and framework
    8·1 answer
  • Structured query language (sql) enables data analysts to _____ the information in a database.
    7·1 answer
  • Explain why you would use the soft on/off jumper when working on ATX system
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!