Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lära Challenge: Array With Powers of Two | Introduction to Arrays
C++ Arrays

bookChallenge: Array With Powers of Two

Uppgift

Swipe to start coding

Write a function that fills an integer array with powers of two. The first element should be 1 (2⁰), the second 2 (2¹), the third 4 (2²), and so on.

  • Declare the array in main with a fixed size of 8.
  • Do not initialize the array when you declare it in main.
  • Complete the function fillPowersOfTwo so that it fills the array with powers of two, starting from 1.
  • Use a loop inside the function to fill the array.

Lösning

Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 3
single

single

Fråga AI

expand

Fråga AI

ChatGPT

Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal

Suggested prompts:

Can you explain this in simpler terms?

What are the main points I should remember?

Can you give me an example?

close

bookChallenge: Array With Powers of Two

Svep för att visa menyn

Uppgift

Swipe to start coding

Write a function that fills an integer array with powers of two. The first element should be 1 (2⁰), the second 2 (2¹), the third 4 (2²), and so on.

  • Declare the array in main with a fixed size of 8.
  • Do not initialize the array when you declare it in main.
  • Complete the function fillPowersOfTwo so that it fills the array with powers of two, starting from 1.
  • Use a loop inside the function to fill the array.

Lösning

Switch to desktopByt till skrivbordet för praktisk övningFortsätt där du är med ett av alternativen nedan
Var allt tydligt?

Hur kan vi förbättra det?

Tack för dina kommentarer!

Avsnitt 1. Kapitel 3
single

single

some-alt