ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Programming Languages  >>  C
 
 


 

 
 C interview questions  C Interview Questions
 C++ interview questions  C++ Interview Questions
 VC++ interview questions  VC++ Interview Questions
 Delphi interview questions  Delphi Interview Questions
 Programming Languages AllOther interview questions  Programming Languages AllOther Interview Questions
Question
How would you write qsort?
 Question Submitted By :: Gvsk05
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How would you write qsort?
Answer
# 1
#include<stdio.h>
#include<conio.h>
void sort(int,int);
int *arr;

void main()
{
clrscr();
int n,ub,lb=0,i;
printf("ENTER NO OF VALUES U WANT TO ENTER : ");
scanf("%d",&ub);
for(i=0;i<ub;i++)
{
	printf("\ENter value : ");
	scanf("%d",&arr[i]);
}
sort(lb,ub);
for(i=0;i<ub;i++)
	printf("%d\t",arr[i]);
getch();
}
void sort(int lb,int ub)
{
	int flag=1,temp,key,i,j;
	i=lb;	j=ub;
	key=arr[i];
	if(lb<ub)
	{
		while(flag)
		{
			i++;
			while(key>arr[i])
				i++;
			while(key<arr[j])
				j--;
			if(i<j)
			{
				temp=arr[i];
				arr[i]=arr[j];
				arr[j]=temp;
			}
			else
				flag=0;
		}
	temp=arr[lb];
	arr[lb]=arr[j];
	arr[j]=temp;
	sort(lb,j-1);
	sort(j+1,ub);
	}
}
 
Is This Answer Correct ?    0 Yes 0 No
Hardik
 

 
 
 
Other C Interview Questions
 
  Question Asked @ Answers
 
How can I convert integers to binary or hexadecimal?  2
main() { char *p; p="Hello"; printf("%c\n",*&*p); } ME2
helllo sir give me some information of the basic information the c as printf ,scanf , %d ,%f and why is the main use of these.  3
how to find that no is int or float?  4
can i know the source code for reversing a linked list with out using a temporary variable? Honeywell3
i want to know aptitude questions,technical questions  1
How to add two numbers without using arithmetic operators? Sapient7
a=0; while(a<5) printf("%d\n",a++); how many times does the loop occurs? a.infinite b.5 c.4 d.6 TCS2
what is meant by c  4
main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf("%d %d\n",x,y); } what is the output? Ramco4
Find Index of least significant bit set in an Integer. ex. int value is say 10001000 results should be 4.  1
how to implement stack work as a queue?  2
study the code: #include<stdio.h> void main() { const int a=100; int *p; p=&a; (*p)++; printf("a=%dn(*p)=%dn",a,*p); } What is printed? A)100,101 B)100,100 C)101,101 D)None of the above Accenture12
what is the different between if-else and switch statment (other than syntax) CTS9
How the C program can be compiled? HP6
Write a C Programm.. we press 'a' , it shows the albhabetical number is 1, if we press 'g' it shows the answer 7.. any can help me  2
What is alloca() and why is its use discouraged?  1
if a person is buying coconuts of Rs10,and then sell that coconuts of Rs9,with the loss of one rupee.After that the person became a millaniore.how? Wipro5
what is the diference between pointer to the function and function to the pointer?  1
What is the main differences between C and Embedded C?  1
 
For more C Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com