Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is page 2 Write a program that produces the following output: Declare an ar

ID: 3648834 • Letter: T

Question


This is page 2


Write a program that produces the following output: Declare an array named: flrstName The array is a c_string. i.e., it is a null-terminated character array The size of the array is 10 Assign 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 to it. Declare an array named: fullName The array is a c_stirng, The size of the array is 20. Don't assign a name to it. In main(): First ask the user for the 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. Make sure to include a space between the names. Call a function named: displayInfo() The function should output the full name and age. (see output)

Explanation / Answer

#include #include int main( ) { char name[7]; /* define a string of characters */ name[0] = 'A'; name[1] = 's'; name[2] = 'h'; name[3] = 'r'; name[4] = 'a'; name[5] = 'f'; name[6] = ''; /* Null character - end of text */ name[7] = ‘X’; clrscr(); printf("My name is %s ",name); printf("First letter is %c ",name[0]); printf("Fifth letter is %c ",name[4]); printf("Sixth letter is %c ",name[5]); printf("Seventh letter is %c ",name[6]); printf("Eight letter is %c ",name[7]); getch(); return 0; } The elements of an array can also be initialized in the array declaration by following the declaration with an equal sign and a comma-separated list (enclosed in braces) of initializers. The following program initializes an integer array with five values and prints the array. #include #include int main() { int numbers[]={1,2,3,4,5}; int i; clrscr(); printf("Array elements are "); for(i=0;i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote