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 |
Give a method to count the number of ones in a 32 bit number?
what is linkage error when it occurs in c program
int *p=20; if u print like dis printf("%d",p); o\p:- 20; how is it possible? plz give me the explanation.
What is extern variable in c with example?
What is a program flowchart?
How to explain the final year project as a fresher please answer with sample project
main() { float a=8.8; double b=8.8; if(a==b) printf("Equal"); else printf("not equal"); getch(); } what is the output? with reason
What is a class c rental property?
Which type of language is c?
How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same
Who is the founder of c language?
Explain how can I open a file so that other programs can update it at the same time?