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
Firlakuza [10]
3 years ago
15

Write a c++ program to print even numbers from 1 to 20​

Computers and Technology
1 answer:
Novay_Z [31]3 years ago
8 0

Answer:

#include <bits/stdc++.h>

using namespace std;

// Function to print even numbers

void printEvenNumbers(int N)

{

cout << "Even: ";

for (int i = 1; i <= 2 * N; i++) {

// Numbers that are divisible by 2

if (i % 2 == 0)

cout << i << " ";

}

}

// Function to print odd numbers

void printOddNumbers(int N)

{

cout << "\nOdd: ";

for (int i = 1; i <= 2 * N; i++) {

// Numbers that are not divisible by 2

if (i % 2 != 0)

cout << i << " ";

}

}

// Driver code

int main()

{

int N = 20;

printEvenNumbers(N);

printOddNumbers(N);

return 0;

}

Explanation:

Note: This will find both odd and even numbers, you have to change the number above to the number of your choice

For even numbers

Even number are numbers that are divisible by 2.

To print even numbers from 1 to N, traverse each number from 1.

Check if these numbers are divisible by 2.

If true, print that number.

For odd numbers

Odd number are numbers that are not divisible by 2.

To print Odd numbers from 1 to N, traverse each number from 1.

Check if these numbers are not divisible by 2.

If true, print that number

You might be interested in
The option to add the date and time to a document is located in the
Tomtit [17]

Answer:

The option to add the date and time to a document is located in the

text grouping on the Insert tab.

Explanation:

8 0
3 years ago
Read 2 more answers
Russian newspaper says U.S. journalism is conducting 'experiments' to introduce fast-growing artificial intelligence technology.
Marina86 [1]

Answer:

Russian newspaper says U.S. journalism is conducting 'experiments' to introduce fast-growing artificial intelligence technology.

Explanation:

Artificial intelligence (AI) is a wide-ranging tool that enables people to rethink how we integrate information, analyze data, and use the resulting insights to improve decision making—and already it is transforming every walk of life. In this report, Darrell West and John Allen discuss AI's application across a variety of sectors, address issues in its development, and offer recommendations for getting the most out of AI while still protecting important human values.

4 0
3 years ago
Read 2 more answers
Does anybody play nitro type
vlabodo [156]

Answer: Nah

Explanation: it kinda sucks and is a waste of time, play better games lol

3 0
3 years ago
Read 2 more answers
4. A friend knows you are taking a technology class in college and asks you how a hard drive works. In your own words, describe
natima [27]
In side the Hard drive there is a  <span> large shiny, circular "plate" of magnetic material called a </span>platter<span>, divided into billions of tiny areas called clusters. This Plate haves a pin over it that reads all the information that is on it. When this plate or pins damage thats when the hard drive need to be replace.   </span>
8 0
3 years ago
How do you protect the server from modification by non-root users?
Elis [28]

Answer:

We can protect the server from the modification by using the non root users in many ways as follows:

  • By modifying the PHP settings in the server and by using the configured file as, the configuration of the file is basically depend upon the linux and the PHP script.
  • By disabling the URL from the function of file handling that basically accept the local file as the parameters but it also accept the URL.  It can even now get to outer destinations by utilizing fsockopen or any of the CURL capacities.
  • The safe mode  of PHP is presumably probably the best alternative to secure your server however it very well may be prohibitive. Whenever initiated, experimental mode averts access to records not claimed by Apache and access to condition factors and execution of double projects are likewise debilitated.

4 0
3 years ago
Other questions:
  • Create a simple main() that solves the subset sum problem for any vector of ints. Here is an example of the set-up and output. Y
    12·1 answer
  • When creating a firewall exception, what is the difference between opening a port and allowing an application through?
    7·1 answer
  • Assign a variable solveEquation with a function expression that has three parameters (x, y, and z) and returns the result of eva
    6·1 answer
  • Which domain refers to the equipment and data an organization uses to support its IT infrastructure. It includes hardware, opera
    15·1 answer
  • Which best describes a difference between transcription and DNA replication
    8·2 answers
  • Find different between manocots and dicots clarify with example​
    14·1 answer
  • You are creating a story map about Mexico. After configuring the web app template, you launch the app to test it. When the app o
    13·1 answer
  • Nicole is in a study group to prepare for a test on plant biology, a subject she knows a lot about. During their meetings, she a
    8·2 answers
  • season is when the weather is not optimal and few tourists of vacation time a shoulder b high c average d low​
    9·2 answers
  • What is the difference between Remote Assistance and Remote Desktop?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!