Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is to be written in C programming. Please do not use pointers/arrays. This exercise focuses on iteration loops. 4 Exercise 3: Functions on powers

This is to be written in C programming. Please do not use pointers/arrays. This exercise focuses on iteration loops.

4 Exercise 3: Functions on powers of 2

TODO: Define and test a function called powers_of_2 that takes an integer n and prints the first n+1 powers of 22 (that is, 20,21,22,23,,2n20,21,22,23,,2n).

The output below demonstrates this functionality with three calls to powers_of_two.

powers_of_two(0) called to print 1 terms: 1 powers_of_two(4) called to print 5 terms: 1 2 4 8 16 powers_of_two(10) called to print 11 terms: 1 2 4 8 16 32 64 128 256 512 1024 

TODO: Define and test a function called sum_powers_of_2 that takes an integer n and returns the sum of the first n+1 powers of 22 :

i=0n2ii=0n2i

That is, it should return: 20+21+22+23++2n20+21+22+23++2n.

The output below demonstrates this functionality with three calls to sum_powers_of_two.

sum_powers_of_two(0) called to sum 1 terms: 1 sum_powers_of_two(4) called to sum 5 terms: 31 sum_powers_of_two(10) called to sum 11 terms: 2047 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Theory And Application Bio Science And Bio Technology International Conferences DTA And BSBT 2011 Held As Part Of The Future Generation In Computer And Information Science 258

Authors: Tai-hoon Kim ,Hojjat Adeli ,Alfredo Cuzzocrea ,Tughrul Arslan ,Yanchun Zhang ,Jianhua Ma ,Kyo-il Chung ,Siti Mariyam ,Xiaofeng Song

2011th Edition

3642271561, 978-3642271564

More Books

Students also viewed these Databases questions

Question

Develop a program for effectively managing diversity. page 303

Answered: 1 week ago

Question

List the common methods used in selecting human resources. page 239

Answered: 1 week ago