If you are using the String class to store your names then you can use the < or > operators to compare the order, alphabetically, they appear in.
String names[3];
int numberOfNames = 3;
names[0] = "abc";
names[1] = "dfg";
names[2] = "hij";
printf("befores%s\n", names[0],names[1],names[2]);
for( int i = 0; i < numberOfNames-1; i++ )
{
for( int j = 0; j < numberOfNames; j++ )
{
if( names[j] < names[j+1] )
{
names[j].swap( names[j+1] );
}
}
}
printf("afters%s\n", names[0],names[1],names[2]);
output:
before abcdfghij
after hijdfgabc
*********************************************************************
this will give correct answer
#include
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]);
return 0;
}
write a program which reads names of students and their telephones from a file and produce a linked list ordered in alphabetical order by the surname of the student.
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.
Use a looping structure. The first step initialises a loop control variable, n, to zero. You then begin the loop by processing the nth element from the array (the process may be a simple print statement). You then increment n. Finally, you test the value of n; if it is less than 10 you start a new iteration of the loop, otherwise you proceed to the end of the flowchart.
To write a C++ program to display the student details using class and array of object.
This sounds like a homework question...
Terms
First, decide on the paragraphs that you would like to use. Write them out in the descending order that you want.
write a program which reads names of students and their telephones from a file and produce a linked list ordered in alphabetical order by the surname of the student.
The polynomial IS written in descending order.
Powers of their exponents
before and after use an conpair the results
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.
das
(6a + 7b)(6a - 7b)
#include(stdio.h) int main ()
Type your answer here... (2x + 5)(4x - 7)
x(x + 2)(x - 5)