Computer Science, asked by seemasharma5431, 4 months ago

Write a program to calculate the amount that will result from the doubling to understand which choice results in a larger amount.​

Answers

Answered by swathi21025
4

Answer:

Given an array and an integer k, traverse the array and if the element in array is k, double the value of k and continue traversal. In the end return value of k.

Examples:

Input : arr[] = { 2, 3, 4, 10, 8, 1 }, k = 2

Output :16

First k = 2 is found, then we search for 4

which is also found, then we search for 8

which is also found, then we search for 16.

Input : arr[] = { 2, 4, 5, 6, 7 }, k = 3

Output :3

Similar questions