Question

1 loop, and 1 selection Below are a list of sequences of numbers. Your job is...

1 loop, and 1 selection

Below are a list of sequences of numbers. Your job is to program each sequence with any loop of your preference (while, for, do/while). I want the code to output the sequence provided and the next number in the sequence (you can output more but there is 1 sequence that may only have 1 number after). . Each sequence should be in the same main in one .cpp file. . Please order and notate each sequence in your output – if you skip one for whatever reason, output the series number and leave the rest blank. The output should also be horizontal like that shown below (if you output it vertically it will be -10pts). Each sequence should be programed with only 1 loop and optionally 1 selection statement.

Series 1:

15, 14, 13, 12, 11, ...

Series 2:

1, 2, 5, 14, 41, ...

Series 3:

2, 3, 5, 8, 12, 17, ...

Series 4:

15, 13, 11, 9, 7, ...

Series 5:

71, 142, 283, 564, 1125, 2246, 4487, 8968, ...

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Program code:

//header files
#include <iostream>
#include<cmath>
using namespace std;

//main method
int main(void)
{
   //variable used to print series
   int i,num,diff;
   num=15;
   //printing the details of series
   cout<<"Series 1:"<<endl;
   for(i=num;i>=0;i--){
       cout<<i<<", ";
   }
   //printing the details of series
   cout<<"\nSeries 2:"<<endl;
   num=1;
   for(i=0;i<=10;i++){
       cout<<num<<", ";
       diff=pow(3,i);
       num=num+diff;
   }
   //printing the details of series
   cout<<"\nSeries 3:"<<endl;
   diff=0;
   num=2;
   for(i=1;i<=10;i++){
       cout<<(num=num+diff)<<", ";
       diff++;
   }
   //printing the details of series
   cout<<"\nSeries 4:"<<endl;
   for(i=15;i>=0;i=i-2){
       cout<<i<<", ";
   }  
   //printing the details of series
   cout<<"\nSeries 5:"<<endl;
   diff=0;
   num=71;
   for(i=1;i<=10;i++){
       cout<<(num=(num*2)-diff)<<", ";
       diff++;
   }

   return 0;
}

Output:

Add a comment
Know the answer?
Add Answer to:
1 loop, and 1 selection Below are a list of sequences of numbers. Your job is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Below are a list of sequences of numbers. Your job is to program each sequence with...

    Below are a list of sequences of numbers. Your job is to program each sequence with any loop of your preference (while, for, do/while). I want the code to output the sequence provided and the next number in the sequence (you can output more but there is 1 sequence that may only have 1 number after). Each sequence should be in the same main in one .cpp file. . Please order and notate each sequence in your output –. The...

  • In Java: The Fibonacci sequence is a series of numbers beginning with 0 and 1, in...

    In Java: The Fibonacci sequence is a series of numbers beginning with 0 and 1, in which each succeeding number is the sum of the previous two.     0, 1, 1, 2, 3, 5, 8, 13, 21, …. Practice your knowledge of recursion by producing a program that prints the nth Fibonacci number. That is, the program should accept an integer (n) as input and output the number that is the nth number in the Fibonacci sequence. For example, if n...

  • 1. Use a for or while loop to assign ID numbers for each student. To make...

    1. Use a for or while loop to assign ID numbers for each student. To make it simple, ID numbers should range from 1 to 18. 2. .Write another loop with if-statement(s) nested inside, to place the students from Problem 1 into 6 groups of three (e.g. Students with ID numbers 1,7 and 13 go into one group, ID numbers 2,8 and 14 go into a second group, etc.). 3. Write a function that outputs the area of a geometric...

  • Using C++ 1. Create a while loop that counts even numbers from 2 to 10 2....

    Using C++ 1. Create a while loop that counts even numbers from 2 to 10 2. Create a for loop that counts by five (i.e. 0, 5, 10, ...) from 0 to 100 3. Ask for a person's age and give them three tries to give you a correct age (between 0 and 100) 4. Use a for loop to list Celsius and Fahrenheit temperatures. The "C" should be from -20 to 20 and the F should be shown correspondingly...

  • LAB5 #1. Method and loop Write a method integerPower(base, exponent) that returns the value of baseexponent...

    LAB5 #1. Method and loop Write a method integerPower(base, exponent) that returns the value of baseexponent (2 pts). For example, integerPower(3, 4) returns 81. Assume thatexponent is a positive nonzero integer, and base is an integer. Method integer should use for or while loop to control the calculation. Do not use any Math library methods. Incorporate this method into a program class and invoke this method with different combinations of input values at least 4 times. Please use printf() method...

  • C# Programming 1-Write a program that generates the following sequence using while loop 2, 3,6,11, 18,...

    C# Programming 1-Write a program that generates the following sequence using while loop 2, 3,6,11, 18, 27,... 102 2-A. Repeat 1 using for loop. B. Modify your program in A to skip 27 from that sequence. C. Modify your program in A by using break statement to stop generating the sequence if the generated number is greater than 30 3. Using loops, find the value of f(7) given: fO)-4, f(n) 2f(n-1)+4, where n is Natural number Hint: f(1)-2f(0)+4-2 4+4-12 f12)-2f(1)+4-...

  • I want this using while loop This using stringin python Use list or some thing in...

    I want this using while loop This using stringin python Use list or some thing in python Using list in python I want answer as soon as posdible E. Last Number time limit per test: 1 second memory limit per test: 256 megabytes input standard input output standard output You are given a sequence of positive integers aj, , 03, ... Print the last element of the sequence. Input The input consists of multiple lines. The i-th line contains a...

  • Fibonacci Sequence The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5,...

    Fibonacci Sequence The Fibonacci Sequence is the series of numbers: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ... The next number is found by adding up the two numbers before it. The 2 is found by adding the two numbers before it (1+1) The 3 is found by adding the two numbers before it (1+2), And the 5 is (2+3), and so on!         Example: the next number in the sequence above is 21+34 = 55 Source:...

  • 12. What is the output of this program? Your answer: 1 def main(): 2 print('The numbers...

    12. What is the output of this program? Your answer: 1 def main(): 2 print('The numbers are:') 3 for i in range (2,25): 4 isone (i) 5 def isone (number): isOne = True i = 2 while i < number and is one: if number % i == 0: 10 isOne = False 11 i += 1 Lou if isOne == True: 13 print("\t', i) 14 main() 12 13. What is the output of this program? Your answer: for i...

  • C# Help Please (Number one is below at the bottom) 1- Write a program that generates...

    C# Help Please (Number one is below at the bottom) 1- Write a program that generates the following sequence using while loop 2, 3 , 6, 11, 18, 27, … , 102 2- A.    Repeat 1 using for loop. B. Modify your program in A to skip 27 from that sequence. C. Modify your program in A by using break statement to stop generating the sequence if the generated number is greater than 30. 3. Using loops, find the value...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT