24 Computer -- Programming Concepts and Logics

WAP to input 50 names and display the longest one and shortest one using arrays.

WAP to input 50 names and display the longest one and shortest one using arrays.

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




 int main(){int a[50],i,n,large,small;printf("How many elements:");scanf("%d",&n);printf("Enter the Array:"); for(i=0;i<n;++i)scanf("%d",&a[i]);large=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 is %d",large);printf("\nThe smallest element is %d",small); return 0;}

More questions on Programming Concepts and Logics

Close Open App