answersLogoWhite

0


Best Answer

int i, x, y, z;

x=1; y=5;

z=1;

for (i=0; i<5; ++i) {

printf ("%d %d ", x, y);

if (x==3) z=z*(-1);

x=x+z;

y=y-z;

}

Output: 1 5 2 4 3 3 4 2 5 1

User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can anyone code this in C plus plus output 1 5 2 4 3 3 2 4 1 5?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is the difference between a plus plus and plus plus a?

a++ returns the value of a and then increments it ++a increments a and then returns the value so the following code: a = 1; std::cout &lt;&lt; a++ std::cout &lt;&lt; ++a std::cout &lt;&lt; a would output 133


What is the code in c plus plus which gives output 1 121 12321 1234321?

#include &lt;iostream&gt; int main() { std::cout &lt;&lt; "1 121 12321 1234321" &lt;&lt; std::endl; return 0; }


What is if in php?

if is very simple, if the given conditions are true than execute the code, if not then move on: $a = 1; if($a == 1) {the code} the ($a == 1) will output true to the if statement, which will execute the code


Can anyone give a code for c plus plus to do a random dice roll for a dropped item when a crate is destroyed?

int die = ((double)rand())*6/RAND_MAX+1; // result is 1, 2, 3, 4, 5, or 6


What are the answers to the a plus computer science output worksheet 1?

There is not a way to cheat on the output worksheet number one. You will just have to do it by hand.


What is the output value for the following function if the input value is 1 y 3x plus 1?

It is 4.


What is -3 plus 1 plus -1 plus -2 plus 2 equals?

9 anyone who does not know this is a kindergartener. then whoever answered this is a kindergartener. the answer is -3


What is OBDII trouble code p0720?

This code is defined as: Output Speed Sensor Circuit


What is the code for Boomerang plus 1 for kids?

it is 2348605 ok


What year did 1 plus area code start?

America


How do you code a program to scan a number n and then output the sum of the power from 1 to n?

help me now !!


Where is this country code from plus 1 016 032?

INVALID CODE +1 is North America, but no valid numbers begin with +1 0.