write a program of bubble sort using pointer?
Answer Posted / gulam md gouss khan
#include<stdio.h>
#include<conio.h>
void sort(int *,int );//prototype
void main()
{
int a[5],size=5; //let suppose
int i;
clrscr();
printf("Enter the elements according to size:");
for(i=0;i<size;i++)
{
scanf("%d",&a[i]);
}
sort(a,size); //calling function
printf(\n\n press any key to exit);
getch();
}
void sort(int *p,int size) //called function
{
int i,j,temp;
for(i=0;i<size-1;i++)
{
for(j=0;j<size-i-1;j++)
{
if(*(p+J)>*(p+j+1))
{
temp=*(p+J);
*(p+J)=*(p+J+1);
*(p+J+1)=temp;
}
}
}
for(i=0;i<size;i++)
{ pritf("%d",*(p+i));
}
| Is This Answer Correct ? | 19 Yes | 12 No |
Post New Answer View All Answers
What is the default value of local and global variables in c?
What are the types of i/o functions?
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]
Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?
When can you use a pointer with a function?
What is a buffer in c?
How can I display a percentage-done indication that updates itself in place, or show one of those twirling baton progress indicators?
What is a structure member in c?
What is the difference between union and anonymous union?
How can I discover how many arguments a function was actually called with?
What is scanf_s in c?
What is file in c preprocessor?
What is an identifier?
How many header files are in c?
Where define directive used?