Monday 31 July 2017

Code for figuring out index ,small valu and large value location



#include"stdio.h"
#include"conio.h"
void min(int[],int);
int i,x[7];
void main()
{
    for(i=0;i<7;i++)
    {
        printf("Enter value of location %d\n",i);
        scanf("%d",&x[i]);
    }
    min(x,7);
    getch();
}
void min(int a[],int size)
{
    int small=a[0],sindex=0,j;
    for(j=1;j<size;j++)
        if(a[j]<small)
        {
            small=a[j];
            sindex=j;
        }
    printf("The small value is %d , Index is %d",small,sindex);
}

0 comments: