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
Arlecino [84]
3 years ago
14

Show the exact output of the following codesegments:(a) for(x=0; x<20; x=x+2)cout<< x << ‘ ‘;cout<< endl ;(

b) i=10;for (;i>0; i =i/2;)cout<< i;
Computers and Technology
1 answer:
egoroff_w [7]3 years ago
3 0

Answer:

a)

for(x=0;x<20;x=x+2)

cout<< x << ' ';

cout<< endl ;

<u>Output</u>

0 2 4 6 8 10 12 14 16 18

In this code we are initialing x with 0, check if it is less than 20, then printing the value 0.

Then we increment x value with 2 and check and print again until the x value tends to be equal or more than 20.

<u>C++ program for verifying</u>

#include <iostream>

using namespace std;

int main()

{

   int x;

   for( x=0;x<20;x=x+2)

      cout<< x << ' ';

      cout<< endl ;

   return 0;

}

<u>Output</u>

0 2 4 6 8 10 12 14 16 18

(You can check on any ide for confirmation)

b)

i=10;

for (;i>0; i =i/2;)

cout<< i;

This code will produce error expected ‘)’ before ‘;’ token

  for(;i>0; i =i/2;)

because for loop consist three parameters and in this loop there are 4 parameters.

If we remove semicolon after i/2,

for(;i>0; i =i/2)

then it will produce an output.

10 5 2 1

<u>C++ program for verifying</u>

#include <iostream>

using namespace std;

int main() {

int i=10;

 for(;i>0; i =i/2;)

 cout<< i;

return 0;

}

<u>Output</u>

Error-expected ‘)’ before ‘;’ token

  for(;i>0; i =i/2;)

You might be interested in
python. create a program that asks the user to input their first name and their favorite number. Then the program should output
blondinia [14]

name = input("What is you name?")

fav_number = input("What is you favorite number?")

print(name + " your favorite number is " + fav_number + "!")

7 0
2 years ago
In order to allow communication between vlans for exchange of data what must be used?​
lana66690 [7]
<span>In order to allow communication between vlans for exchange of data what must be used?

Router must be used</span>
4 0
3 years ago
Maeve has created the website, but she is not able to include more than one blank space at a time. Even if she hits the SPACE bu
GenaCL600 [577]

Answer:

For the browser to display multiple spaces, Maeve must use &nbsp; in her code to create more spaces.

Explanation:

&nbsp; is known as hard space or fixed space. NBSP stands for Non-Breaking Space. The statement will continue without breaking into another line.

Maeve can easily use the &nbsp; many times to get the required space she needs.

5 0
3 years ago
What is the output from this program? #include void do_something(int *thisp, int that) { int the_other; the_other = 5; that = 2
Ostrovityanka [42]

Answer:

  1  35

Explanation:

* There is a little typo in printf. It should be "\n".

Initially, the value of the first is 1, and the value of the second is 2. Then, do_something(&second, first) is called. The value of the <em>first</em> will still be 1. However, there is a call by reference for <em>second </em>variable. That means the change made by the function <em>do_something</em> will affect the value of the <em>second</em> variable.

When you look at the calculation inside the <em>do_something</em> function, you may see that value of the <em>second</em> will be 35.

7 0
3 years ago
Analyze the following code.
denis-greek [22]

Answer:

C

Explanation:

No explanation, self-explanatory. I used class main instead...

4 0
3 years ago
Other questions:
  • The spreadsheet below shows the names years in office, and number of terms for five US presidents
    7·2 answers
  • Assume that name has been declared suitably for storing names (like "amy" , "fritz" and "moustafa") write some code that reads a
    5·1 answer
  • Which of the following variable declarations is a correct assignment?
    14·1 answer
  • A web __________, such as internet explorer or mozillaâs firefox, allow users to access the world wide web.
    10·1 answer
  • Which technology enables afloat forces to communicate more securely and to operate in a more dispersed manner?
    6·1 answer
  • C++
    8·1 answer
  • What is Processor to Memory Mismatch problem?
    15·1 answer
  • Please help. 15 points!!!!
    8·2 answers
  • Plz help Complete the sentence.
    11·2 answers
  • What are the routes through with Virus transmitted into computer<br>system?​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!