#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int i,j,d;
char ch[20],temp;
clrscr();
printf("\nEnter the no.of string:");
scanf("%d",&d);
printf("\nEnter the strings:");
for(i=0;i<d;i++)
{
gets(ch[i])
}
printf("\nThe strings are:");
for(i=0;i<d;i++)
{
printf("\n%s",ch[i]);
}
for(i=0;i<d;i++)
{
for(j=i+1;j<d;j++)
if(ch[i]>ch[j])
{
temp=ch[i];
ch[i]=ch[j];
ch[i]=temp;
}
}
getch();
}
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main(){
int i,j,n;
char str[20][20],temp[20];
puts("Enter the no. of string to be sorted");
scanf("%d",&n);
for(i=0;i<=n;i++)
gets(str[i]);
for(i=0;i<=n;i++)
for(j=i+1;j<=n;j++){
if(strcmp(str[i],str[j])>0){
strcpy(temp,str[i]);
strcpy(str[i],str[j]);
strcpy(str[j],temp);
}
}
printf("The sorted string\n");
for(i=0;i<=n;i++)
puts(str[i]);
getch();
return 0;
}
#include
#include
#include
using namespace std;
void sortString(char array[], int num);
void outputString(char array[], int num);
int main() {
int columns=30, rows=0;
char filename[30], letter;
ifstream fin;
cout << "Enter the file name: ";
cin >> filename;
fin.open(filename);
if (!fin) {
cout << "Failure to open the file.";
} else {
while (fin >> letter) {
if (letter == '\n')
rows++;
}
fin.clear();
fin.seekg(0,ios::beg);
char name[rows][columns];
rows = 0;
while (fin.get(name[rows][columns])) {
rows++;
}
sortString(name, rows+1);
outputString(name, rows+1);
}
return 0;
}
void sortString(char array[], int num) {
int i, j;
char check[num][30];
for (i=1; i strcpy(check, array[i][30]); for (j=1; j>=1 && (strcmp(check, array[30][j-1])==1); j--) { array[j][30] = array[j-1][30]; array[j-1][30] = check; } } } void outputString(char array[], int num) { for (int i=0; i cout << array[i][30] << endl; } } The above would be correct if the question required a C++ solution. The code could not be compiled with a C compiler. Rows is is initialized to zero and the next time rows is referenced is char name[rows][columns]; And as soon as while (fin.get(name[rows][columns])) { rows++; } is executed the program will crash.
#include <stdio.h> #include <conio.h> #include <string.h> void main() { char name[10][8], Tname[10][8], temp[8]; int i, j, N; clrscr(); printf("Enter the value of N\n"); scanf("%d", &N); printf("Enter %d names\n", N); for(i=0; i< N ; i++) { scanf("%s",name[i]); strcpy (Tname[i], name[i]); } for(i=0; i < N-1 ; i++) { for(j=i+1; j< N; j++) { if(strcmpi(name[i],name[j]) > 0) { strcpy(temp,name[i]); strcpy(name[i],name[j]); strcpy(name[j],temp); } } } printf("\n----------------------------------------\n"); printf("Input Names\tSorted names\n"); printf("------------------------------------------\n"); for(i=0; i< N ; i++) { printf("%s\t\t%s\n",Tname[i], name[i]); } printf("------------------------------------------\n"); } /* End of main() */
#include<iostream> #include<set>
#include<string>
int main()
{
using namespace std;
multiset<string> strings;
string input;
cout << "Enter strings in any order (end with empty string):\n" << endl;
while (getline(cin, input))
{
if (input=="")
break;
strings.insert (input);
}
cout << "\nIn ascending order:\n" << endl;
for (auto s : strings)
cout << s << endl;
}
Use strcmp function to compare the strings. A sample C code is available in below link. Just refer it for more information.
s4sourcecode.online/2020/02/c-program-to-sort-list-of-names-in.html?m=1
uitihyiuiphoiphuihyi
Writing a C program that uses dynamic memory allocation to sort names in ascending order is a typical computer science assignment. To write this program, you must be in UNIX.
No. They can be sorted either ways. Ascending or Descending.
public class BubbleSortAscendingOrderDemo { public static void main(String a[]) { //Numbers which need to be sorted int numbers[] = {23,5,23,1,7,12,3,34,0}; //Displaying the numbers before sorting System.out.print("Before sorting, numbers are "); for(int i = 0; i < numbers.length; i++) { System.out.print(numbers[i]+" "); } System.out.println(); //Sorting in ascending order using bubble sort bubbleSortInAscendingOrder(numbers); //Displaying the numbers after sorting System.out.print("Before sorting, numbers are "); for(int i = 0; i < numbers.length; i++) { System.out.print(numbers[i]+" "); } }
Using sorted(array,reverse=True)
uitihyiuiphoiphuihyi
Writing a C program that uses dynamic memory allocation to sort names in ascending order is a typical computer science assignment. To write this program, you must be in UNIX.
You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.You can sort the data in ascending or descending order.
To sort from smallest to largest. Ascending means to go up.
ascending sort
import java.util.Arrays; public class arraysort { public static void main(String[] a) { int array[] = { 2, 5, -2, 6, -3 }; Arrays.sort(array); for (int i : array) { System.out.println(i); } } }
In ascending order and in descending order.
No. They can be sorted either ways. Ascending or Descending.
In ascending order, perhaps!
You can sort dates as you would sort regular data, highlight the range and click on sort and pick the order you want.
That they appear in alphabetical order... A, B, C. ... and so on.
The sort buttons. You can use them to sort in ascending order or descending order. One has A above Z with a down arrow enabling you to sort in ascending order. The other has Z above A with a down arrow enabling you to sort in descending order. Once your data is selected, you can click the appropriate button to do the sort you want.