Define a character array named nameArray that contains the first 7 letters of yo
ID: 3917213 • Letter: D
Question
Define a character array named nameArray that contains the first 7 letters of your full name as the array's elements in sequence. For e.g., for someone named Jon. P. Doe, the variable should e: char nameArravlTE registration records) and use all uppercase characters. If your full name has more than 7 letters, take the first 7 letters. If your full name has less than 7 letters, pad it by repeating characters. For. e.g. if your name is Xu Li, pad it like so: {X.U','L'XLy DEFINE CHARACTER ARRAY INCLUDING INITIALIZATIONExplanation / Answer
C++ code:
I have given 3 methods for the given question, Please find the code below
#include <iostream>
#include <string>
using namespace std;
int main() {
//method 1
char nameArray[] = {'B','E','B','O','B','E','B'};
//Method 2
char nameArray2[]= "BEBOBEB";
//Method 3
string nameArray3 = "BEBOBEB";
return 0;
}
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.