wap for bubble sort
Answers were Sorted based on User's Feedback
Answer / guru1985
#include<stdio.h>
#include<conio.h>
void main()
{
int a[20],i,j,r,temp;
printf("Enter the Range:");
scanf("%d",&r);
for(i=0;i<r;i++)
{
printf("Enter the Eliment No. %d",i+1);
scanf("%d",&a[i]);
}
for(i=0;i<r;i++)
{
temp=0;
for(j=i+1;j<r;j++)
{
if(a[i]>a[j])
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
}
}
printf("After Sorting:");
for(i=0;i<r;i++)
{
printf("\n%d",a[i]);
}
}
| Is This Answer Correct ? | 15 Yes | 4 No |
Answer / mandeep m gaba
//n=No of elements in an array;
int n;
int []a;
for(i=0;i<n;i++)
{
for(j=0;j<n-i;j++)
{
if(a[j]>a[j+1])
{ //swap function for the variables in the array
int temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
| Is This Answer Correct ? | 11 Yes | 8 No |
Answer / sachin
n=No of elements in an array;
for(i=0;i<n;i++)
{for(j=0;j<n-i;j++)
{if(arr[j]>arr[j+1])
swap(arr[j],arr[j+1]);
}
}
void swap(int*x, int*y)
{
int temp;
temp = *x;
*x = *y;
*y = temp;
}
| Is This Answer Correct ? | 7 Yes | 10 No |
Given an int variable n that has been initialized to a positive value and, in addition, int variables k and total that have already been declared, use a do...while loop to compute the sum of the cubes of the first n whole numbers, and store this value in total . Thus if n equals 4, your code should put 1*1*1 + 2*2*2 + 3*3*3 + 4*4*4 into total . Use no variables other than n , k , and total .
What is probability to guarantee that the task a programmer is going to create will be created and be able to run on a particular system (RTOS/GPOS).
#include"stdio.h" #include"conio.h" void main() { int a; printf("\n enter a number:"); scanf("%c\n"); getch(); }
#include<stdio.h> void main() { int i=1; printf("%d%d%d",i++,++i,i); }
void main() { int i=5,y=3,z=2,ans; clrscr(); printf("%d",++i + --z + i++ + --i * ++y); i=5,y=3,z=2; ans=++i + --z + i++ + --i * ++y; printf("\n%d",ans); getch(); } Its output is 37 and 31.... Please explain me why its different How it works.....
how tally is useful?
void main() { int i=5; printf("%d",i+++++i); }
UINT i,j; i = j = 0; i = ( i++ > ++j ) ? i++ : i--; explain pls....
what is meant by linking error? how can i solve it? if there is a linking error " unable to open file 'cos.obj'? then what should i do?
I'm having trouble with coming up with the correct code. Do I need to put a loop? Please let me know if I'm on the right track and what areas I need to correct. I still don't have a good grasp on this programming stuff. Thanks =) The assignment was to write a program using string functions that accepts a coded value of an item and displays its equivalent tag price. The base of the keys: 0 1 2 3 4 5 6 7 8 9 X C O M P U T E R S Sample I/O Dialogue: Enter coded value: TR.XX Tag Price : 68.00
main() { char c; for(c='A';c<='Z';c++) getch(); }
Write a c-programe that input one number of four digits and find digits sum?