If I'm understanding correctly, you want to alternate between two numbers back and forth?
If so, try something like this:
/* num1 is the number to be alternated
and alt is the amount of times do so */
int num1 = 1;
int alt;
/* Get number of times to alternate */
cout << "Enter number of times to alternate: ";
cin >> alt;
/* Perform alternation and cout result each time */
for (int i = 0; i < alt; i++)
{
num1 *= -1; // in this case, alternating positive/negative
cout << num1 << endl;
}
Note that you can change the "num1 *= -1" to whatever you need.
For example, to alternate between 50 and 25, you would put
/* Starting with 50, then alternating to 25 for the first cout */
num1 = 50;
/* On odd times through (1,3,5), ADD 25;
On even times through (0,2,4...etc) SUBTRACT 25 */
if ( (i % 2) == 1)
{
num1 += 25;
}
else
{
num1 -= 25;
}
Input a variable.
sum = a + b + c;
#define biggest (a) > (b) && (a) > (c) ? (a) : (b) > (c) ? (b) : (c)
By learning how to program on C+.
you can play it by not pressing down any keys. OR for low c#, all six keys plus the second left pinky key (low C plus the pinky). this can be alternate fingering with an octave key
The format of floating-point numbers. On some platforms.
how do we use loops in c plus plus programing and what are basic differences between do,for and while loop
int main() { int x = 40 + 2; }
how to write a program that counts automorphic number from 1 to 999
R = (A > B && A > C) ? A : (B > C) ? B : C; // parentheses not necessary - for clarity only
This is the associative law for addition: If a, b, c are any numbers then: a + (b + c) = (a + b) + c
Yes that about sums it up.