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

in C programming 3. Write a program that takes the list char examsAreTough /5120

ID: 3918377 • Letter: I

Question

in C programming

3. Write a program that takes the list char examsAreTough /5120)-One" "Two Three Four", "Five" l and alphabetizes through the alphatizing process. A second for) loop then the array Create a for) loop that prints off all five in sequence each time uses stremp) to co mpare the string to the next string in the list.If they are not already in alphabetical order, swap the two strings using strepy0 (and a temporary char array), Execute this comparison multiple ti loops). The end result should be an array that is ['Five", "Four""One,"Three" Two mes( for) loops inside foro Expected output of your program 0-One 1- Two 2 - Three 3- Four 4- Five 0-One 1 - Three 2- Four 3- Five 4 -Two 0 - One 1 Four 2- Five 3 - Three 4- Two 0- Four 1 - Five 2 -One 3 - Three 4- Two 0 - Five 1- Four 2-One 3-Three 4 - Two

Explanation / Answer

#include <stdio.h>
#include <string.h>

int main() {
   int i, j;
   char examsAreTough[5][20] = {"One", "Two", "Three", "Four", "Five"};
   char temp[20];
   for(i = 0; i < 5; i++) {
       for(j = 0; j < 5; ++j) {
           printf("%d - %s ", j, examsAreTough[j]);
       }
       for(j = 0; j < 4; j++) {
           if(strcmp(examsAreTough[j], examsAreTough[j+1]) > 0) {
               strcpy(temp, examsAreTough[j]);
               strcpy(examsAreTough[j], examsAreTough[j+1]);
               strcpy(examsAreTough[j+1], temp);
           }
       }
   }
   return 0;
}