Found 1 Questions For Find Largest Element in Array

Write C Program to Find Largest Element in Array in C Programming

Updated on 17-Jan-2022 9:02:21
Program : Find Largest Element in Array in C Programming #include<stdio.h> int main() { int a[30], i, num, largest; printf("\nEnter no of elements :"); scanf("%d", &num); //Read n elements in an array for (i = 0; i < num; i++) scanf("%d", &a[i]); //Consider first element as largest largest = a[0]; for (i = 0; i < num; i++) { if (a[i] > largest) { largest = a[i]; } } // Print out the Result printf("\nLargest Element : %d", largest); return ... Read Mores



Advertisements

ads