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 |
write a proram to reverse the string using switch case?
Is c easy to learn?
yogesh patil in dell
What is floating point exception error? And what are different types of errors occur during compile time and run time? why they occur?
Once I have used freopen, how can I get the original stdout (or stdin) back?
What are structural members?
Write a program in "C" to calculate the root of a quadratic equation ax^2+bx+c=0, where the value of a,b & c are known.
int i=~0; uint j=(uint)i; j++; printf(“%d”,j);
What is a far pointer?What is the utility?
Difference between constant pointer and pointer to a constant.
Why does the call char scanf work?
Explain how do you search data in a data file using random access method?