This is page 2 Write a program that produces the following output: Declare an ar
ID: 3648834 • Letter: T
Question
This is page 2
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;iRelated 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.