C program to print smallest number in Array.

A program to find Smallest number in Array in C.

 

 

Array : An Array is a collection of data items, all of the same type,

               accessed using a common name.

 

 

Let’s write a program which print smallest number in an Array.

 

 

Let’s open Turbo C and write the following code.

 

Code:

 

 

// Add preprocessor

 

#include<stdio.h>

#include<conio.h>

void main()

{

long int i,min,n[10];

 

//Clear Screen

clrscr();

printf(“enter all numbers :”);

for(i=0;i<10;i++)

{

scanf(“%li”,&n[i];

}

for(i=0;i<10;i++)

{

if(min>n[i])

{

min=n[i];

}

}

 

// Print the Result

printf(“smallest number is: \n %li”,min);

getch();

}

 

Output:

 

 

OUTPUT

 

 

Happy Coding

Tags: , , , , ,