#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
void select(char *items, int count);
int main(void)
{
char s[255];
printf("Enter a string:");
gets(s);
select(s, strlen(s));
printf("The sorted string is: %s.\n", s);
getch();
return 0;
}
void select(char *items, int count)
{
register int a, b, c;
int exchange;
char t;
for(a = 0; a < count-1; ++a)
{
exchange = 0;
c = a;
t = items[ a ];
for(b = a + 1; b < count; ++b)
{
if(items[ b ] < t)
{
c = b;
t = items[ b ];
exchange = 1;
}
}
if(exchange)
{
items[ c ] = items[ a ];
items[ a ] = t;
}
}
}



design an algorithm for Selection Sort


No Answer is Posted For this Question
Be the First to Post Answer

Post New Answer

More OOPS Interview Questions

what are the uses of C++

1 Answers  


1. Wrie a function which returns the most frequent number in a list of integers. Handle the case of more than one number which meets this criterion. public static int[] GetFrequency(int[] list)

1 Answers   Nagarro,


Given two strings like x=?hello? and y=?open?, remove any character from string x which is also used in string y, thus making the result x=?hll?.

13 Answers   IBM,


what is pointers

7 Answers   Exilant,


different types of castings

3 Answers   Siemens,






function overridind means and simple program

2 Answers  


I am developing a payroll system mini project.I used file concept in program for reading and writing.When the program is reloading into the memory that is if i execute next time the file was cleaned and adding data from the starting this is my problem.I want to strore the previous data and if i want to add any record that should be next of previous data.Please help me.

0 Answers  


What are the two different types of polymorphism?

0 Answers  


What is abstract class in oops?

0 Answers  


what is ltti

1 Answers   Unisys,


create a c++ program that will accepts 9 inputs using 3 by 3 array.

1 Answers  


Is this job good for future? can do this job post grduate student?

0 Answers  


Categories