Question 19

You do not have access for this page.


To access this page please purchase:
TCS Ninja Coding Questions Products
TCS Ninja Online Live Classes


Note:- Please purchase the products mentioned above to get access to the page. Also, if you have any queries related to product purchase drop a message on our Facebook page.

Please Login/Signup to comment

One comment on “Question 19”


  • Abhirup Nag

    #include
    #include

    void read_array(int *arr,int n);
    void print_array(int *arr,int n);
    void find_minandmax(int *arr,int n,int *min,int *pos1,int *max,int *pos2);
    int main()
    {
    int score[10],n,min = 32767,pos1,max = -32767,pos2;
    printf(“\nEnter the size of the array\n”);
    scanf(“%d”,&n);
    read_array(score,n);
    print_array(score,n);
    find_minandmax(score,n,&min,&pos1,&max,&pos2);
    printf(“\nscore[%d] = %d Therefore %d is minimum element in %d position\n “,pos1,min,min,pos1);
    printf(“\nscore[%d] = %d Therefore %d is maximum element in %d position\n”,pos2,max,max,pos2);
    return 0;
    }
    void read_array(int *arr,int n)
    {
    int i;
    printf(“Enter the element in the array\n”);
    for(i=0;i<n;i++)
    {
    printf("score[%d] = ",i);
    scanf(" %d",&arr[i]);
    }

    }
    void print_array(int *arr,int n)
    {
    int i;
    printf("\nTHE ARRAY ELEMENTS ARE:");
    for(i=0;i<n;i++)
    {
    printf("\nscore[%d]=%d",i,arr[i]);
    }
    }
    void find_minandmax(int *arr,int n,int *min,int *pos1,int *max,int *pos2)
    {
    int i;
    for(i=0;i<n;i++)
    {
    if(*(arr+i) < *min)
    {

    *min = *(arr+i);
    *pos1 = i;
    }

    }

    int j;
    for(j=0;j*max)
    {
    *max = *(arr+j);
    *pos2 = j;
    }
    }

    }