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...

  • 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...

  • 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...

  • 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:...

  • ​Declare an array with 1000 elements of type int Then in a loop generate 1000 random numbers and assign one to each element in the array The random numbers should be between 1 and 50 Then, prompt the user to enter a number, store this number in a local

    Rules to follow are:Declare an array with 1000 elements of type intThen in a loop generate 1000 random numbers and assign one to each element in the arrayThe random numbers should be between 1 and 50do not use rand or srand, use code is providedThen, prompt the user to enter a number, store this number in a local variable, the number should be safety checked using the GetInteger() functionThen, iterate through the array and determine how many times the user's...

  • NOTE: Write the Program in python as mentioned below and use while loop and flags as...

    NOTE: Write the Program in python as mentioned below and use while loop and flags as necessary. And please write the code following the program description given below. DON'T use Function concept or any other concept except while loop,if-else. Directions: Read the program description below carefully. All requirements must be met by your program to receive full credit. Thus, pay particular attention to input and output requirements, structural requirements, and so on. Furthermore, code that contains syntax errors will not...

  • Java please 9:55 Note @13 simple lists of numbers. If the user selects option 2, your...

    Java please 9:55 Note @13 simple lists of numbers. If the user selects option 2, your program should prompt for a list of integer grades (0 100, inclusive). When the list is entered print out the following statistics: total grades, the breakdown of grades by letter both count and percentage), the highest and lowest grades in the list, and the class average Example #1 Please enter a list of grades (0-100): 55 65 75 85 95-1 Total number of grades...

  • NOTE: Write the Program in python as mentioned below and use while loop and flags as...

    NOTE: Write the Program in python as mentioned below and use while loop and flags as necessary. And please write the code following the program description given below. Directions: Read the program description below carefully. All requirements must be met by your program to receive full credit. Thus, pay particular attention to input and output requirements, structural requirements, and so on. Furthermore, code that contains syntax errors will not receive any credit, so be sure that your code interprets correctly...

  • repl,it HW 11.2 Please verify your em back to classroom run i.mport random 2 # DO...

    repl,it HW 11.2 Please verify your em back to classroom run i.mport random 2 # DO NOT DELETE you may want to collapse it. 4- def generate_number_strings (): 3 wGenerates a string that contai ns digits and spaces. 6 numbers- 7 rng range(random.randint (1, 20) 8 for i in rng: 10- if (len(numbers)> and numbers[-1:] != and i !-rng. stop and random.randint (0, 10) % 50): 11 12 13 1 14- numbers + 15 else: 16- numbers +str(random . randint...

  • Consider the problem in the below figure. Your goal is to find the places of the digits from 1 to 9 in grey cells i...

    Consider the problem in the below figure. Your goal is to find the places of the digits from 1 to 9 in grey cells in such a way that if a number is given between adjacent cells then the sum of the digits in these cells must be equal to that number. You can use each digit only once. 7 13 12 14 7 15 Formulate this problem as a mixed-integer linear program by defining binary decision variables. As you...

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
ADVERTISEMENT