You had a few issues with formatting and making it nice to even enter numbers. You also had some of your loops a bit off with their counters etc. Here is your code with a few tweaks to make it work a bit nicer...
cpp
#include<stdio.h>
#include<conio.h>
#define SIZE 80
void main()
{
int a[SIZE],i,temp,j,n;
printf("enter the size: ");
scanf("%d",&n);
printf("enter the nos.\n");
for(i=0;i<n;i++)
{
printf("Number: ");
scanf("%d",&a[i]);
printf("a[%d] = %d\n",i, a[i]);
}
for(i=0;i<n-1;i++)
{
// We want to make sure that J always starts at 0 but subtracts
// i (the last value bubbled)
for(j=0;j<n-1-i;j++)
{
// Notice here that we use j + 1 not + i
if(a[j]>a[j + 1])
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("the result is:\n");
for(i=0;i<n;i++)
{
printf("%d\n",a[i]);
}
getch();
}
Normally I wouldn't setup a bubblesort like this, but I just figured I would show you the error of your ways and let you handle it from there. The way I like to do it is with bubbling to the end of the array and using a flag to let you know if any swaps have been made. It makes the sort a bit more efficient, especially for arrays that are close to being sorted.
Enjoy!
"At DIC we be messed up bubble sorting code ninjas... deformed bubble sorting perhaps? Interesting."