Untitled
unknown
plain_text
5 months ago
739 B
7
Indexable
#include <iostream> #include <string> using namespace std; int main() { string firstName, lastName; int number; // Input first name, last name, and a four-digit number cin >> firstName >> lastName >> number; // Get the first six characters of the first name, or the entire first name if it's shorter than 6 characters string firstPart = firstName.substr(0, 6); // Get the first letter of the last name char lastPart = lastName[0]; // Get the last digit of the number using the modulus operator int lastDigit = number % 10; // Generate and output the login name cout << "Your login name: " << firstPart << lastPart << "_" << lastDigit << endl; return 0; }
Editor is loading...
Leave a Comment