Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Working with the Array | Variables and Data Types
C++ Introduction
course content

Course Content

C++ Introduction

C++ Introduction

1. Getting Started
2. Variables and Data Types
3. Introduction to Operators
4. Introduction to Program Flow
5. Introduction to Functions

bookWorking with the Array

Reminder how to access an array by index

cpp

main

copy
12345678910
#include <iostream> int main() { int myArray[3] = { 67, 23, 87 }; std::cout << myArray[0] << std::endl; std::cout << myArray[1] << std::endl; std::cout << myArray[2] << std::endl; }

Note

Index counting starts from zero, making the first element in a list or array the zeroth element.

Task

  • Declare a string array with a size of 5;
  • Initialize the array with the following values:
    • First element: "!";
    • Second element: "World";
    • Third element: ",";
    • Fourth element: "Hello";
    • Fifth element: " ".
  • Construct the message by arranging the elements of the array in the correct order ("Hello, world!")and then set it to the value of the message variable;
  • Output the constructed message.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 7
toggle bottom row

bookWorking with the Array

Reminder how to access an array by index

cpp

main

copy
12345678910
#include <iostream> int main() { int myArray[3] = { 67, 23, 87 }; std::cout << myArray[0] << std::endl; std::cout << myArray[1] << std::endl; std::cout << myArray[2] << std::endl; }

Note

Index counting starts from zero, making the first element in a list or array the zeroth element.

Task

  • Declare a string array with a size of 5;
  • Initialize the array with the following values:
    • First element: "!";
    • Second element: "World";
    • Third element: ",";
    • Fourth element: "Hello";
    • Fifth element: " ".
  • Construct the message by arranging the elements of the array in the correct order ("Hello, world!")and then set it to the value of the message variable;
  • Output the constructed message.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 7
toggle bottom row

bookWorking with the Array

Reminder how to access an array by index

cpp

main

copy
12345678910
#include <iostream> int main() { int myArray[3] = { 67, 23, 87 }; std::cout << myArray[0] << std::endl; std::cout << myArray[1] << std::endl; std::cout << myArray[2] << std::endl; }

Note

Index counting starts from zero, making the first element in a list or array the zeroth element.

Task

  • Declare a string array with a size of 5;
  • Initialize the array with the following values:
    • First element: "!";
    • Second element: "World";
    • Third element: ",";
    • Fourth element: "Hello";
    • Fifth element: " ".
  • Construct the message by arranging the elements of the array in the correct order ("Hello, world!")and then set it to the value of the message variable;
  • Output the constructed message.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Reminder how to access an array by index

cpp

main

copy
12345678910
#include <iostream> int main() { int myArray[3] = { 67, 23, 87 }; std::cout << myArray[0] << std::endl; std::cout << myArray[1] << std::endl; std::cout << myArray[2] << std::endl; }

Note

Index counting starts from zero, making the first element in a list or array the zeroth element.

Task

  • Declare a string array with a size of 5;
  • Initialize the array with the following values:
    • First element: "!";
    • Second element: "World";
    • Third element: ",";
    • Fourth element: "Hello";
    • Fifth element: " ".
  • Construct the message by arranging the elements of the array in the correct order ("Hello, world!")and then set it to the value of the message variable;
  • Output the constructed message.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Section 2. Chapter 7
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
some-alt