How do you write a program that prints out the alphabet out to the "nth" letter? For example, if the user inputs a 1, it will print out "a". If the user inputs a 5, it will print out "abcde", and if the user inputs 10, it will print out "abcdefghij" and so on?
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
usingnamespace std;
int main() {
int number;
string letter;
cout<<"Enter a number 1-26";
cin>>number;
//letter= // i want to convert the number into the alphabet up until the nth letter
cout<<"The alphabet to the "<<number<<"th letter is "<<letter;
}
#include <iostream>
usingnamespace std;
int main()
{
int n;
cout << "Enter a number (1-26): "; cin >> n;
for ( char c = 'a'; c < 'a' + n; c++ ) cout << c;
}