#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

#include <iostream> using namespace std; int main() { int a = 2; int c[5][5]; for (int x=0;x<5;x++) { for (int y=0;y<5;y++) { c[x][y] = x*y; } } cout << c[a][c[1][4]]; }

2 Answers   TCS, Wipro,


what does exactly the linker do?

1 Answers  


What is encapsulation selenium?

0 Answers  


Why do we use oops?

0 Answers  


why the argument is passed by reference to a copy constructor?example?

2 Answers  






What polymorphism means?

0 Answers  


What is this interview room ? Is it a class or an object.

3 Answers   CybAge, NSN, Wipro,


What is the Advantage of Interface over the Inheritance in OOPS?

4 Answers  


WILL I GET A guaranteed JOB AFTER DOING bsc()IT) and GNIIT from an NIIT CENTRE??

21 Answers   Biocon, MIT, NIIT,


write a program to find 2^n+1 ?

0 Answers   CTS,


What is a linked list?

7 Answers   IBM, Neural Info,


Finding of the 4 larger (bigger) numbers from the list like{1245,4587,2145,1163,29987,65783.....}

1 Answers   Wipro,


Categories