Using C (not C++ or C#) I need help in solving the following problem. So I have the persisting code and I want to modify void SortNicknames(String10 friends[], int n) which will sort the friends[] array alphabetically (in increasing order). Use the straight selection sorting algorithm. (To test the function by calling it inside main() immediately before the call to PrintNicknames() function. ) #include #include typedef char String10 [11]; void InputNicknames ( String10 friends [] , int n ) { int i ; for ( i = 0; i < n ; i ++) { printf (" Input the nickname of your friend : " ); scanf ("%s" , friends[ i ]); } } void PrintNicknames ( String10 friends [] , int n ) { int i ; printf (" \n "); printf (" The nicknames of your friends are :\ n "); for ( i = 0; i < n ; i ++) { printf (" %s \n " , friends[ i ]); } } int main () { String10 friends [5]; InputNicknames ( friends , 5); PrintNicknames ( friends , 5); return 0; }
Using C (not C++ or C#) I need help in solving the following problem. So I have the persisting code and I want to modify void SortNicknames(String10 friends[], int n) which will sort the friends[] array alphabetically (in increasing order). Use the straight selection sorting
(To test the function by calling it inside main() immediately before the call to PrintNicknames() function. )
#include<stdio.h>
#include <string.h> typedef char String10 [11];
void InputNicknames ( String10 friends [] , int n )
{
int i ;
for ( i = 0; i < n ; i ++) {
printf (" Input the nickname of your friend : " );
scanf ("%s" , friends[ i ]);
}
}
void PrintNicknames ( String10 friends [] , int n )
{
int i ;
printf (" \n ");
printf (" The nicknames of your friends are :\ n ");
for ( i = 0; i < n ; i ++) {
printf (" %s \n " , friends[ i ]);
}
}
int main ()
{
String10 friends [5];
InputNicknames ( friends , 5);
PrintNicknames ( friends , 5); return 0;
}
Step by step
Solved in 4 steps with 3 images