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

bookChallenge: Array With Powers of Two

Tehtävä

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.

Ratkaisu

Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 3
single

single

Kysy tekoälyä

expand

Kysy tekoälyä

ChatGPT

Kysy mitä tahansa tai kokeile jotakin ehdotetuista kysymyksistä aloittaaksesi keskustelumme

close

bookChallenge: Array With Powers of Two

Pyyhkäise näyttääksesi valikon

Tehtävä

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.

Ratkaisu

Switch to desktopVaihda työpöytään todellista harjoitusta vartenJatka siitä, missä olet käyttämällä jotakin alla olevista vaihtoehdoista
Oliko kaikki selvää?

Miten voimme parantaa sitä?

Kiitos palautteestasi!

Osio 1. Luku 3
single

single

some-alt