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
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
C++ Arrays

bookChallenge: Array With Powers of Two

Opgave

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 alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 3
single

single

Spørg AI

expand

Spørg AI

ChatGPT

Spørg om hvad som helst eller prøv et af de foreslåede spørgsmål for at starte vores chat

close

bookChallenge: Array With Powers of Two

Stryg for at vise menuen

Opgave

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 desktopSkift til skrivebord for at øve i den virkelige verdenFortsæt der, hvor du er, med en af nedenstående muligheder
Var alt klart?

Hvordan kan vi forbedre det?

Tak for dine kommentarer!

Sektion 1. Kapitel 3
single

single

some-alt