how can i sort numbers from ascending order and descending
order using turbo c..
Answer Posted / neha
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("before %s%s%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("after%s%s%s\n", names[0],names[1],names[2]);
output:
before abcdfghij
after hijdfgabc
| Is This Answer Correct ? | 4 Yes | 6 No |
Post New Answer View All Answers
What do you know about the use of bit field?
What is the best organizational structure?
What is zero based addressing?
What is selection sort in c?
Is javascript written in c?
What is the importance of c in your views?
What are the data types present in c?
in programming languages a statement or part of a statement that specifies several different execution sequences a) constructs b) distructs c) executes d) none
List some of the dynamic data structures in C?
hw can we delete an internal node of binary search tree the internal node has child node..plz write progarm
What is difference between && and & in c?
What is infinite loop?
Why c is called free form language?
In cryptography, you could often break the algorithm if you know what was the original (plain) text that was encoded into the current ciphertext. This is called the plain text attack. In this simple problem, we illustrate the plain text attack on a simple substitution cipher encryption, where you know each letter has been substituted with a different letter from the alphabet but you don’t know what that letter is. You are given the cipherText as the input string to the function getwordSets(). You know that a plain text "AMMUNITION" occurs somewhere in this cipher text. Now, you have to find out which sets of characters corresponds to the encrypted form of the "AMMUNITION". You can assume that the encryption follows simple substitution only. [Hint: You could use the pattern in the "AMMUNITION" like MM occurring twice together to identify this]
When would you use a pointer to a function?