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

bookChallenge: Array With Powers of Two

Oppgave

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

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 3
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

close

bookChallenge: Array With Powers of Two

Sveip for å vise menyen

Oppgave

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 desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 3
single

single

some-alt