0

c program to find the largest number in an array using function

20th Apr 2020, 3:29 AM
bibin varghese
bibin varghese - avatar
5 Answers
+ 2
no its my own
20th Apr 2020, 3:57 AM
VIVEK NIRMALKAR
VIVEK NIRMALKAR - avatar
0
#include <stdio.h> int main() { int i, n; int arr[100]; printf("Enter the number of elements (1 to 100): "); scanf("%d", &n); for (i = 0; i < n; ++i) { printf("Enter number%d: ", i + 1); scanf("%d", &arr[i]); } // storing the largest number to arr[0] for (i = 1; i < n; ++i) { if (arr[0] < arr[i]) arr[0] = arr[i]; } printf("Largest element = %d", arr[0]); return 0; }
20th Apr 2020, 3:55 AM
VIVEK NIRMALKAR
VIVEK NIRMALKAR - avatar
0
This is not using function
30th Sep 2021, 10:26 AM
Bharath