google.com, pub-6167773875660516, DIRECT, f08c47fec0942fa0 Write a program to find the largest element of an array - 2nd puc computer science

Write a program to find the largest element of an array

Write a program to find the largest element of an array

#include<stdio.h>

#include<conio.h>

void main()

{

int a[10],large,i,n;

clrscr();

printf("How many elements? ");

scanf("%d",&n);

printf("Enter the elements\n");

for(i=0;i<n;i++)

scanf("%d",&a[i]);

large=a[0];

for(i=0;i<n;i++)

{

         if(a[i]>large)

         large=a[i];

}

printf("Largest element is %d",large);

getch();

}

Output:

How many elements? 5

Enter the elements                                                             

3                                                                              

1                                                                              

2                                                                              

5                                                                               

4                                                                              

Largest element is 5
Write a program to find the largest element of an array Write a program to find the largest element of an array Reviewed by Vision Academy on December 12, 2021 Rating: 5

No comments:

CheckOut

Powered by Blogger.