how to write a bubble sort program without using temporary
variable?
Answer / nitin garg
#include <stdio.h>
#include <conio.h>
#include <string.h>
int main()
{
int num[100],n,i,j;
printf("how many elements you enter
");
scanf("%d",&n);
printf("Enter %d elements
",n);
for(i=0;i<n;i++)
{
scanf("%d",&num[i]);
}
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(num[j]>num[i])
{
num[i]=num[i]+num[j];
num[j]=num[i]-num[j];
num[i]=num[i]-num[j];
}
}
}
printf("
Sorted in Ascending order
");
for(i=0;i<n;i++)
{
printf("%d
",num[i]);
}
getch();
}
| Is This Answer Correct ? | 15 Yes | 4 No |
How do I get an accurate error status return from system on ms-dos?
What is the use of header?
Write a program which returns the first non repetitive character in the string?
What are pointers in C? Give an example where to illustrate their significance.
write a program for egyptian fractions in c?
What is wrong in this statement? scanf(“%d”,whatnumber);
What does & mean in scanf?
What are void pointers in c?
What is the need of structure in c?
Is main() is used in the program,,see below example? void main() { int i; for(i=0;i<10;i++) main(); } Then what is the output of the program?
Why clrscr is used after variable declaration?
Explain what is the purpose of "extern" keyword in a function declaration?