Question: Consider the below series : 0, 0, 2, 1, 4, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8 This series is a mixture of 2 series all the odd terms in this series form even numbers in ascending order and every even terms is derived from the previous term using the formula (x/2) Write a program to find the nth term in this series. The value n in a positive integer that should be read from STDIN the nth term tha is calculated by the program should be written to STDOUT. Other than the value the nth term no other characters /strings or message should be written to STDOUT. For example if n=10,the 10 th term in the series is to be derived from the 9th ter in the series. The 9th term is 8 so the 10th term is (8/2)=4. Only the value 4 shou De printed to STDOUT. You can assume that the n will not exceed 20,000. C Code: #include

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter8: Arrays And Strings
Section: Chapter Questions
Problem 21PE
icon
Related questions
Question

 

 

Question: Consider the below series :
0, 0, 2, 1, 4, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8
This series is a mixture of 2 series all the odd terms in this series form even
numbers in ascending order and every even terms is derived from the previous
term using the formula (x/2)
Write a program to find the nth term in this series.
The value n in a positive integer that should be read from STDIN the nth term that
is calculated by the program should be written to STDOUT. Other than the value of
the nth term no other characters /strings or message should be written to
STDOUT.
For example if n=10,the 10 th term in the series is to be derived from the 9th term
in the series. The 9th term is 8 so the 10th term is (8/2)=4. Only the value 4 should
be printed to STDOUT.
You can assume that the n will not exceed 20,000.
C Code:
#include <stdio.h>
Transcribed Image Text:Question: Consider the below series : 0, 0, 2, 1, 4, 2, 6, 3, 8, 4, 10, 5, 12, 6, 14, 7, 16, 8 This series is a mixture of 2 series all the odd terms in this series form even numbers in ascending order and every even terms is derived from the previous term using the formula (x/2) Write a program to find the nth term in this series. The value n in a positive integer that should be read from STDIN the nth term that is calculated by the program should be written to STDOUT. Other than the value of the nth term no other characters /strings or message should be written to STDOUT. For example if n=10,the 10 th term in the series is to be derived from the 9th term in the series. The 9th term is 8 so the 10th term is (8/2)=4. Only the value 4 should be printed to STDOUT. You can assume that the n will not exceed 20,000. C Code: #include <stdio.h>
Expert Solution
steps

Step by step

Solved in 5 steps with 2 images

Blurred answer
Knowledge Booster
Computational Systems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr