Im trying to write a program that produces the following output. /* Output Enter
ID: 3649312 • Letter: I
Question
Im trying to write a program that produces the following output./* Output
Enter: your age: 21
Enter the last age: Lee
Hello Tom Lee. Your are 21 Years Old
Press any key to continue.... */
Declare an array named: firstName
- The array is a c_string. i.e. (it is a null-terminated character array).
- The size of the array is 10
- Assing a first name to it when it is declared.
Declare an array named: lastName
- The array is a c_string
- The size of the array is 10.
- Don't assign a name it.
Declare an array named: fullName
- The array is c_string.
- The size of the array is 20.
- Dont assign a name it.
In main():
- First ask the user for age.
- Read the age and assign it to a variable.
- Then ask the user for the last name.
- Read the last name and assign it to lastName.
- Assign the first and last names to fullName.
- Make sure to include a space between the names.
Call a function named: displayInfo()
The function should output the full name and age.
Explanation / Answer
please rate - thanks
#include <iostream>
using namespace std;
int main()
{char firstName[10]="Tom";
char lastName[10];
char fullName[20];
int age;
cout<<"Enter your age: ";
cin>>age;
cout<<"Enhter your Last Name: ";
cin>>lastName;
strcpy(fullName,firstName);
strcat(fullName," ");
strcat(fullName,lastName);
cout<<"Hello "<<fullName<<". You are "<<age<<" Years old ";
system("pause");
return 0;
}