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
Please help, I can't find the answer but I understand the topic.
gladu [14]

Answer:

x=(2+3)*3;

Explanation:

3 0
3 years ago
Read 2 more answers
Which of the following is a type of intangible business property that is protected by law
xz_007 [3.2K]
Google might be it ok
6 0
3 years ago
How long will my chromebook last if it is at 30 percent
Marta_Voda [28]

Answer:

You can see an estimated battery life time.

Explanation:

To see it simply put your mouse over the battery icon, don't click it and it should give you the life it has left in hours:minutes format.

5 0
3 years ago
Which windows component can be used to display information such as weather forecasts?
azamat
The bottom right widgeti
6 0
3 years ago
The three of hazards<br>​
Paul [167]

Answer:

Please be more specific

Explanation:I take digital technology information so I might be able to help you.

6 0
3 years ago
Other questions:
  • Background Susan finished work on system architecture issues, and her system design specification was approved. Now she is ready
    15·1 answer
  • What type of link is used to call this file
    11·1 answer
  • How does coding work on computers?
    6·1 answer
  • 5. Write a program to remove any duplicate letters from a word and display the new word maintaining the original order. For exam
    12·1 answer
  • Please answer quick:))))
    7·1 answer
  • I don't know the answer and I tried different ones and they not what the book is looking for.
    7·1 answer
  • Create a program that prints out a list of all the divisors of a number stored in a variable. (If you don’t know what a divisor
    11·1 answer
  • What are the answers for edhesive quiz 2? I can’t add more than 1 photo...
    11·1 answer
  • Giving brainliest if you answer question.
    8·1 answer
  • A function checkZeros accepts three double parameters. It checks to see if the sum of all three parameters is equal to zero. If
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!