Skip to main content
Search
Search This Blog
Livecodo
Pages
Home
Courses
Blog
About us
More…
Share
Get link
Facebook
X
Pinterest
Email
Other Apps
March 28, 2024
Write a C program to find the largest integer in a list of integers
#include
int main() { int a[25], i, large, small, n; printf("Enter the size of array(max 25)\n"); scanf("%d", &n); printf("Enter any %d integer array elements\n",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 element from the given array is %d \nThe smallest element from the given array is %d", large, small); return 0; }
Popular Posts
March 26, 2024
Dynamic Memory allocation in C
May 18, 2024
Searching and sorting Algorithm in C