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
RideAnS [48]
3 years ago
9

Write a for loop that will print the values 1 to 20 while skipping the odd numbers (2,4,6,8,10,12,14,16,18,20):

Computers and Technology
1 answer:
DochEvi [55]3 years ago
6 0

<u>Answer:</u>

<em>void main ( )  </em>

<em> {  </em>

<em> int counter;  </em>

<em>  cout<<""Even numbers between 1 to 20 are:""<<endl ;  </em>

<em> //Method 1 </em>

<em>  for (counter = 1; counter <= 20; counter++)  </em>

<em>  {  </em>

<em>    if ( counter%2 == 0)  </em>

<em>   {   </em>

<em>     cout<<counter<<""\t""<<endl ;  </em>

<em>   }  </em>

<em>  }  </em>

<em>//Method 2 – simplest one </em>

<em>for (counter = 2; counter <= 20;)  </em>

<em>  {  </em>

<em>     cout<<counter<<""\t""<<endl ;  </em>

<em>counter = counter + 2; </em>

<em>    </em>

<em>  } </em>

<em> </em>

<em>  return 0;  </em>

<em>} </em>

<u>Explanation:</u>

In this, Method 1 runs a for loop and check whether each number is divided by 2. If yes, then printed otherwise it is skipped.

In the second method, it runs for loop only for even numbers. <em>This is obtained by incrementing the counter by 2. </em>

You might be interested in
An electronic cover letter should be
Lunna [17]
A cover letter is a document sent with your resume to provide additional details about you. The cover letter is what introduces your resume and you. 
<span>A few short tips for writing cover letters. i dont know if thats the answer you looking for</span>
3 0
3 years ago
Read 2 more answers
What is Morse code???
aev [14]
TEETEE TEE TEE TEE TEETEETEE
4 0
3 years ago
Read 2 more answers
What is the proper structure of the variable that represents the translatable static text in Template Content?
Lubov Fominskaja [6]

{!Text.VariableName} is the proper structure of the variable that represents the translatable static text in Template Content

A. {!Text.VariableName}

<u>Explanation:</u>

In browser, content translation is possible to translate from one language to other languages, so that the end-user can easily understand the content in their own language.

Normally the text content is translated to the end-user language. As universal containers admin merger the fields so transaction output will be static text.

Suppose in browser  system prompt for translate to default language setting  once the end-user select current web page is translated to selected or default language.

8 0
3 years ago
The quality of lacking a pattern or organization so that results are unpredictable is known as:
myrzilka [38]

Answer:

Randomness

Explanation:

We could know about randomness in different ways, for example in the lottery, it's going to play a randomness number in this case.

In video games the randomness is commonly used, for example in roulettes, also, randomness it could be a danger, for example in casino games, and for an <u>organization</u> is not the best ways to keep data or results, always we must know the goal's organization, and keep a path about that.

7 0
4 years ago
7.8.1: Function pass by reference: Transforming coordinates. Define a function CoordTransform() that transforms the function's f
Lilit [14]

Answer:

Here is the CoordTransform() function:              

void CoordTransform(int xVal, int yVal, int &xValNew, int &yValNew){

xValNew = (xVal + 1) * 2;

yValNew = (yVal + 1) * 2; }

The above method has four parameters xVal  and yVal that are used as input parameters and xValNew yValNew as output parameters. This function returns void and transforms its first two input parameters xVal and yVal into two output parameters xValNew and yValNew according to the formula: new = (old + 1) *

Here new variables are xValNew  and yValNew and old is represented by xVal and yVal.

Here the variables xValNew and yValNew are passed by reference which means any change made to these variables will be reflected in main(). Whereas variables xVal and yVal are passed by value.

Explanation:

Here is the complete program:

#include <iostream>

using namespace std;

void CoordTransform(int xVal, int yVal, int &xValNew, int &yValNew){

xValNew = (xVal + 1) * 2;

yValNew = (yVal + 1) * 2;}

int main()

{ int xValNew;

int yValNew;

int xValUser;

int yValUser;

cin >> xValUser;

cin >> yValUser;

CoordTransform(xValUser, yValUser, xValNew, yValNew);

cout << "(" << xValUser << ", " << yValUser << ") becomes (" << xValNew << ", " << yValNew << ")" << endl;

return 0; }

The output is given in the attached screenshot   

7 0
3 years ago
Other questions:
  • Driving while wearing headphones or earphones
    12·2 answers
  • A security analyst is investigating a call from a user regarding one of the websites receiving a 503: Service unavailable error.
    10·1 answer
  • The instant pivot button is displayed in the statistics and visualization tabs when a _______ search is run.
    15·1 answer
  • Given storeMonthlySales NUM STOREST[NUM MONTHST[NUM DEPTS] is a three-dimensional array of floating point values. Write a C++ fu
    5·1 answer
  • If your computer won't connect to the internet, which of these is most likely to be the problem?
    8·1 answer
  • A horse is how much percent more powerful than a pony
    11·1 answer
  • Cite an early photographic pioneer or invention. Explain their/its impact on photography as we know it today.
    14·1 answer
  • Does anybody have the full answer sheet for Cisco Packet Tracer 11.10.1 (Design and implement a vlsm addressing scheme)? Will gi
    14·1 answer
  • How can I convert a string to a int? in Java
    13·1 answer
  • An outpatient provides the following id: barbara jones, birth date 8/15/63. should a specimen be collected for this lab order?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!