Search
 
SCRIPT & CODE EXAMPLE
 

C

C Program to Find Largest and Smallest Number among N

// C program to find the smallest and largest element in an array

#include<stdio.h>

int main()
{
int a[50],i,n,large,small;
printf(“
Enter the number of elements : “);
scanf(“%d”,&n);
printf(“
Input the array elements : “);
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 smallest element is %d
”,small);
printf(“
The largest element is %d
”,large);

return 0;
}
Comment

PREVIOUS NEXT
Code Example
C :: toupper function in c 
C :: array reference argument 
C :: c convert char to int 
C :: how to make sure input is integer c 
C :: c sleep milliseconds 
C :: c programming how to force stop the programme 
C :: celsius to fahrenheit formula 
C :: c program to find the frequency of all characters in a string 
C :: Bitwise Operators in C/C++ 
C :: print variable adress c 
C :: getting string input in c 
C :: Bootstrap textarea from 
C :: c sizeof operator 
C :: quick sort c 
C :: selection sort c 
C :: mongo script to find collection size in database 
C :: c print 
C :: pendu langage c 
C :: choose random number with weight 
C :: c extern 
C :: getline function in c 
C :: c malloc array 
C :: logical operators in c 
C :: what is %d in C 
C :: C Syntax of return statement 
C :: program in c to print 1 to 100 without using loop 
C :: amazon kinesis disaster recovery 
C :: how to get out of function in c 
C :: first come first serve 
C :: python project script run 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =