answer.
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
Readme [11.4K]
1 year ago
8

Given positive integer n, write a for loop that outputs the even numbers from n down to 0. If n is odd, start with the next lowe

r even number. Hint: Use an if statement and the % operator to detect if n is odd, decrementing n if so. Enter an integer: 7 Sequence: 64 20 (2) If n is negative, output 0, Hint: Use an if statement to check if n is negative. If so, just set n = 0. Enter an integer: -1 Sequence: 0 Show transcribed image text (1) Given positive integer n, write a for loop that outputs the even numbers from n down to 0. If n is odd, start with the next lower even number. Hint: Use an if statement and the % operator to detect if n is odd, decrementing n if so. Enter an integer: 7 Sequence: 64 20 (2) If n is negative, output 0, Hint: Use an if statement to check if n is negative. If so, just set n = 0. Enter an integer: -1 Sequence: 0
Computers and Technology
1 answer:
seropon [69]1 year ago
7 0

Answer:

The program in Python is as follows:

n = int(input("Enter an integer: "))

if n < 0:

   n = 0

print("Sequence:",end=" ")

for i in range(n,-1,-1):

   if i%2 == 0:

       print(i,end = " ")

Explanation:

This gets input for n

n = int(input("Enter an integer: "))

This sets n to 0 if n is negative

<em>if n < 0:</em>

<em>    n = 0</em>

This prints the string "Sequence"

print("Sequence:",end=" ")

This iterates from n to 0

for i in range(n,-1,-1):

This check if current iteration value is even

   if i%2 == 0:

If yes, the number is printed

       print(i,end = " ")

You might be interested in
A firm that wanted to enable its employees to use and share data without allowing outsiders to gain access could do so by establ
Bess [88]

Answer:

Intranet

Explanation:

An organization owns a private network which is called an intranet. Private means that the network is accessible to all those employed within the organization, staff of the company.

Intranet exists only within the company and indicates the following.

1. The company establishes its own network inside the company so that the staff of the company can access and exchange information among themselves.

2. The staff can communicate and have discussions on the network.

3. The information is not accessible to outside parties such as customers, stakeholders, and others.

4. The network is not accessible and does not exists for the outside parties.

5. The term intra means inside and net means network.  

Intranet leads to the following benefits.

1. The staff can view and exchange information with more ease and comfort and in less time.

2. Faster access to information increases employee output. Employees can perform better and have more time to focus on their work.

3. Communication among the employees is encouraged and made easy. Any one can communicate with every one in the company.

4. More communication leads to better working relationships among the staff. Cooperation and collaboration among the staff is given a boost.

5. Staff can give their input for the type of information to be held in the respository. This serves as the single point of information which enables smooth work flow.

Intranet also has some drawbacks.

The employees can take undue advantage of this communication channel for personal communications and information exchange.

Unproductive communication can only hamper the culture of the workplace.

Guidelines should be enforced to avoid unnecessary communication.  

Technologies

Intranet can be implemented by using both local area and wide area networks ( LAN and WAN ). The infrastructure needed for the intranet includes the resources used in both LAN and WAN.

3 0
2 years ago
While rendering the homepage of a website, it takes a lot of time due to the thread being blocked in processing JS/CSS. What are
jekas [21]

Answer:

a) Pick ONE OR MORE options Using code-splitting for JS files.

b) Compressing the JS files on the server-side

Explanation:

Javascript is a multi-purpose programming language, it is used in web development as a scripting language for programming the interactiveness of the web application.

Loading and running the script from the server can take a lot of time, so, the file is compressed and split for faster loading.

6 0
2 years ago
Joe, Kate and Jody are members of the same family. Kate is 5 years older than Joe. Jody is 6 years older than Kate . The sum of
mezya [45]

Answer:

5, 10 and 16

Explanation:

The sum of their ages is √961 = 31

If Joe is x years old, the equation that follows is:

x + (x+5) + (x+5+6) = 31

This simplifies to

3x = 31 - 11 - 5 = 15

so x=5

From that you can find

Joe = x = 5

Kate = x+5 = 10

Jody = x+5+6 = 16

5 0
2 years ago
Read 2 more answers
Write a function so that the main() code below can be replaced by the simpler code that calls function MphAndMinutesToMiles(). O
babymother [125]

Answer:

The program to this question can be given as:

Program:

#include <iostream> //header file

using namespace std; //using namespace

double MphAndMinutesToMiles(double milesPerHour, double minutesTraveled) //defining method

{

return (minutesTraveled/ 60.0)*milesPerHour; //return value.

}

int main() //defining main method

{

double milesPerHour,minutesTraveled; //define variable

cout<<"Enter miles per hour :";  

cin >> milesPerHour;  

cout<<"Enter travelling minutes :";

cin >> minutesTraveled;

cout << "Miles: "<< MphAndMinutesToMiles(milesPerHour, minutesTraveled)<< endl;

return 0;

}

Output:

Enter miles per hour :12

Enter travelling minutes :20

Miles: 4

Explanation:

The explanation of the above C++ program can be given as:

  • In the first header file is include the function is define that is "MphAndMinutesToMiles". This function accepts two parameters that are "milesPerHour and minutesTraveled".
  • Both parameter datatype is double and the function return type is also double. Inside a function calculate miles and return its value.
  • In the main method, two variable defines that takes value from the user side and pass into the function. To print function return value we use "cout" function that prints function return value.
6 0
2 years ago
When excel follows the order of operations the formula 8 * 3 + 2 equals?
Airida [17]
It follows the normal convention of BODMAS , which is the order of precedence of operations , so the answer equals to 26
3 0
2 years ago
Other questions:
  • What is a cursor?
    6·2 answers
  • A router is involved in ____________ layers of the tcp/ip protocol suite.
    12·1 answer
  • Suppose you define a java class as follows: public class test { } in order to compile this program, the source code should be st
    14·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    11·1 answer
  • A website updated daily could be considered _____. a. authoritative b. objective c. accurate d. timely
    8·1 answer
  • Database management systems are expected to handle binary relationships but not unary and ternary relationships.'
    7·1 answer
  • Look at the following array definition:
    11·1 answer
  • In this challenge, write a function to add two floating point numbers. Determine the integer floor of the sum. The floor is the
    8·1 answer
  • A video game character can face toward one of four directions: north, south, east, and west. Each direction is stored in memory
    15·1 answer
  • Write a class named Employee that has private data members for an employee's name, ID_number, salary, and email_address. It shou
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!