Business

C Program to Input N Numbers and Find Greatest and Smallest

Write a C program to input ‘n’ numbers and find out greatest and smallest number.

C Program to Input N Numbers and Find Greatest and Smallest Number.
Source Code, 

#include <stdio.h>
#include <conio.h>
void main()
{
int i,n,num[100],largest,smallest;
clrscr();
printf("Enter the value of n");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter any number");
scanf("%d",&num[i]);
}
largest=num[0];
smallest=num[0];
for(i=0;i<n;i++)
{
if(largest<num[i])
largest=num[i];
if(smallest>num[i])
smallest=num[i];
}
printf("Largest number=%d",largest);
printf("nSmallest number=%d",smallest);
getch();
}

Show More

J. Satya

Started blogging in 2010 but working professionally from 2012. Apart from that working as a Digital Marketer, SEO & Conversion Specialist. Helping individuals as well as business to grow.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button
Close
Close