HOW TO SOLVE THIS questions ??? MAY YOU EXPLAIN IF YOU WANT TO RUN IT #include <
ID: 3781246 • Letter: H
Question
HOW TO SOLVE THIS questions ???
MAY YOU EXPLAIN
IF YOU WANT TO RUN IT
#include <stdio.h>
#include <string.h>
int main(void){
char strings[][80] = {"THIS", "EASY", "ICS103", "EXAM"};
char str[80] = " ";
int k, m = 0, index;
for(k = 3; k >= 0; k--){
index = strlen(strings[k]) - 1;
str[m] = strings[k][index];
printf("%s ", str);
m++;
}
for(m = strlen(str) - 1; m >= 0; m--){
printf("%c", str[m]);
}
return 0;
}
ICS 103 Final Exam Term 152 17 points #includeExplanation / Answer
// C code explanation
#include <stdio.h>
#include <string.h>
int main(void)
{
// declare and define array of string
char strings[][80] = {"THIS", "EASY", "ICS103", "EXAM"};
// declare and define empty string
char str[80] = " ";
// declare local variables
int k, m = 0, index;
// for loop to iterate over the index of array of strings
for(k = 3; k >= 0; k--)
{
// index stores the length of string at index k subtracted by 1
index = strlen(strings[k]) - 1;
// str is assigned the character at kth row and index column
str[m] = strings[k][index];
// print the string
printf("%s ", str);
// increment m
m++;
}
// iterate over string str and print it in reverse
for(m = strlen(str) - 1; m >= 0; m--){
printf("%c", str[m]);
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.