0
Can someone help me?
#include <iostream> using namespace std; int main() { char arr[] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'}; char letters[26]; // Declare an array for letters with the same size as 'arr'. // Copy the values from 'arr' to 'letters'. for (int i = 0; i < 26; i++) { letters[i] = arr[i]; } cout << letters[1]; // This will print the second letter 'b' (index 1) from the 'letters' array. } this is what I have so far. Task: Take a number as input and output the letter from the array that corresponds to that index.
3 Respostas
0
You don't know how do enter user data?
0
Building on what you have
int index;
cin >> index;
index %= 26;
cout << letter [index];
0
Just do cin>>index, declare int index first of course and then you just need to do cout << letters[index].