//Proram to Intialize, Insertion and sorting in array....
#include
int main(void)
{
int mark[5];
int i;
printf("Enter the marks of student");
for(i=0;i<5;i++)
{
printf("Enter the marks of %d student",i);
canf("%d",&mark[i]);
}
printf("\n marks submitted succesfully");
printf("\n marks entered by you are");
for(i=0;i<5;i++)
{
printf("\n marks of %d studentis= %d",i,mark[i]);
printf("\t addres location is =%d", &mark[i]);
}
printf("\n----Welcome to search----");
int num;
printf("Enter number you want to search");
scanf("%d",&num);
for (i=0;i<5;i++)
{
if(num==mark[i])
{
printf("Element found at %d Location",i);
printf("\t Address Location is=%d",&mark[i]);
break;
}
}
if(i==5)
{
printf("Oops--Element not found");
}
int temp;
printf("~~~~~~WelCome To searching~~~~~~~");
int j;
for(j=0;j<5;j++)
{
for(i=0;i<4;i++)
{
if(mark[i] > mark[i+1])
{
temp=mark[i];
mark[i]=mark[i+1];
mark[i+1]=temp;
}
}
}
printf("Values after sorting are");
printf("\n");
for(i=0;i<5;i++)
{
printf("\n Element %d is=%d",i,mark[i]);
printf("\t Address is =%d",&mark[i]);
}
}
No comments:
Post a Comment