Menu

[Solved] C Programming Question Explain Line Code Thoroughly Beginner Could Understand Code Include Q37210433

C Programming question: Explain each line of the code belowthoroughly so a beginner could understand.

Code:

#include<stdio.h>
int main(){
int i,j;
char inputString[3000];
int array[300];

printf(“Enter input string : “);
fgets(inputString,3000,stdin);

for(i=0; i<300; i++)
array[i] = 0;

for(i=0; inputString[i]; i++) //Using Hashing to store frequencyof every character
array[inputString[i]]++;

printf(“n1. After ascending sorting : “); //printing the hasharray in forward manner.
for(i=0; i<300 ; i++)
for(j=0; j<array[i]; j++)
printf(“%c”,i);

printf(“n”);
printf(“n2. After descending sorting : “); //printing the hasharray in reverse manner.
for(i=299; i>=0 ; i–)
for(j=0; j<array[i]; j++)
printf(“%c”,i);

printf(“n”);
for(i=0 ; i<300; i++) //printing the frequency of everycharacter in the hash array.
if(array[i]>0)
printf(“Frequency of %c is %d .n”,i,array[i]);

I’m having a hard time explaining this code as I’m in an introto C programming class, please help me understand what this codedoes and what each main line of this program code does please.

Expert Answer


Answer to C Programming question: Explain each line of the code below thoroughly so a beginner could understand. Code: #include in… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *