1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Simple solution to find largest & smallest number in array.

Discussion in 'C' started by kabirk007, Jan 27, 2009.

Thread Status:
Not open for further replies.
  1. kabirk007

    kabirk007 New Member

    Code:
    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    int a[10],n,i,large,small;
    printf("enter the value of n\n");
    scanf("%d",&n);
    printf("enter the numbers\n");
    for(i=0;i<n;i++)
    scanf("%d",&a[i]);
    large=a[0];
    small=a[0];
    for(i=1;i<n;i++)
    {
    if(a[i]>large)
    large=a[i];
    if(a[i]<small);
    small=a[i];}
    printf("The largest number is %d\n",large);
    printf("smallest number is %d\n",small);
    getch();
    }
     
    Last edited by a moderator: Jan 27, 2009
  2. shabbir

    shabbir Administrator Staff Member

Thread Status:
Not open for further replies.

Share This Page