C Programming
- Print integer
- Add & subtract
- Odd & even
- Multiply & divide
- Check vowels
- Letter grade program
- Leap year program
- Sum of digits
- Prime numbers
- Sum of numbers
- Find factorial
- Fibonacci series
- Fibonacci triangle
- Number triangle
- Alphabet triangle
- Armstrong numbers
- Palindrome numbers
- Swap number
- Reverse number
- Decimal to binary
- Assembly code in C
- Matrix multiplication
- HCF & LCM
- nCr & nPr
- Print pattern
- Floyd’s triangle
- Pascal triangle
- Count digits
- Strong numbers
- Perfect numbers
- Sum of natural number
- Binary to decimal
- Decimal to octal
- Octal to decimal
- Binary to octal
- Octal to binary
- Add using pointer
- Bubble sort
- Insertion sort
- Selection sort
- Quick sort
- Binary search
- Linear search
- Largest element of array
- Smallest element of array
- Reverse Array
- Variable size & limit
- ASCII value of character
- Sum of array elements
- Number of element in array
- Merge two array
- Insert element in array
- Delete element from array
- Add two matrix
- Transpose matrix
- Print string
- Reverse string
- Delete vowels
- Sort string
- Remove spaces
- Swap string
- Random numbers
- Print date & time
- Print IP address
- Shut down computer
Find smallest element in an array using C
C program to find smallest element of any array. To find that number we will assume the first element as the smallest number among all other numbers of that array. Then compare it with other elements and take the new smallest number if the second number is smaller than that number.
However, you can write code to serve this purpose in different way using function, recursion or pointer. Let’s see some program to take the idea to do this.
C program to find smallest element of array
// find smallest number of an array in C
#include <stdio.h>
int main(){
int y, num_array[50], arr_size, indx = 0;
printf("Enter how many number you have for the array : ");
scanf("%d", &arr_size);
printf("Enter all array elements here : \n", arr_size);
for(y = 0; y < arr_size; y++){
scanf("%d", &num_array[y]);
}
for(y = 1; y < arr_size; y++){
if(num_array[y] < num_array[indx]){
indx = y;
}
}
printf("\nMinimum element at location %d and it is = %d.\n", indx + 1, num_array[indx]);
return 0;
}
Output of smallest element program:

We can do the same program using function, recursion or pointers. You can also count that how many times the maximum number remains in our array. For doing this simply you can take another variable for count the occurrence. Try this program in your own. Now we will see the program to find smallest integers of an array using pointer in C.
Find smallest element of array using pointer in C
// find smallest number of an array using pointer in C
#include <stdio.h>
int main(){
int a, *min_num, arr_size, indx = 1, my_array[50];
printf("Enter how many number of the array : ");
scanf("%d", &arr_size);
printf("Enter all array element here : \n");
for(a = 0; a < arr_size; a++){
scanf("%d", &my_array[a]);
}
min_num = my_array;
*min_num = *my_array;
for(a = 1; a < arr_size; a++){
if(*(my_array + a) < *min_num){
*min_num = *(my_array + a);
indx = a + 1;
}
}
printf("\nMinimum number at location %d which is = %d.\n", indx, *min_num);
return 0;
}
See program output here :
Enter how many number of the array : 12
Enter all array element here :
65 45 34 65 75 32 62 18 54 24 29 50
Minimum number at location 8 which is = 18.
Previous page:Â Largest element in array
Next page:Â Reverse array