PetraAI / Additional algorithm 15.cpp
PetraAI's picture
Upload 136 files
3da5d57
//Paul A. Gagniuc. An Introduction to Programming Languages: Simultaneous Learning in Multiple Coding Environments. Synthesis Lectures on Computer Science. Springer International Publishing, 2023, pp. 1-280.
//Additional algorithm 15. It shows how to access the values stored in the elements of an array variable. An array literal is declared, in which three string values (three separate characters, namely "a", "b", "c") are stored. Then, two variables x and y are declared, which take values from the elements of the array variable A. Then, once assigned to the x and y variables, the string values are displayed in the output for visualization. As it can be observed, the result obtained after the execution is "bc". Note that the source code is in context and works with copy/paste.
#include <iostream>
using namespace std;
int main()
{
string A[] = {"a", "b", "c"};
string x = A[1];
string y = A[2];
cout<<(x + y);
return 0;
}