Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » BeginnersRSS Feeds

Program to find greatest number from one dimensional array

Posted By: Leah Hughes     Category: C Programming     Views: 19539

Write a program to find greatest number from one dimensional array.

Code for Program to find greatest number from one dimensional array in C Programming

#include<stdio.h>
#include<conio.h>

int main()
{
    int a[20],n,i,max=0;  // declared the array a with size  20
    clrscr();

    printf("\n Enter  the number of elements for 1-D array : ");
    scanf("%d",&n);

    for(i=0;i<n;i++)
    {
        printf("\n Enter element [%d] : ",i+1);
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        if(max<a[i])
            max=a[i];
    }

    printf("\n Greatest element from above array inserted is : %d",max);

    getch();

    return 0;
}


Output:

Enter  the number of elements for 1-D array : 5

Enter element [1] : 1
Enter element [2] : 8
Enter element [3] : 2
Enter element [4] : 5
Enter element [5] : 9

Greatest element from above array inserted is: 9
  
Share: 


Didn't find what you were looking for? Find more on Program to find greatest number from one dimensional array Or get search suggestion and latest updates.

Leah Hughes
Leah Hughes author of Program to find greatest number from one dimensional array is from London, United Kingdom.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!