Skip to main content

Posts

Showing posts from April 21, 2021

Program to find Smallest element in an array using C

  Program to find Smallest element in an array using C We will find the smallest or minimum element in an array using the C concept. We apply an algorithm that assumes the first element as the smallest element and then compares it with other elements if an element is smaller than it then, it becomes the new smallest element, and this process is repeated till the complete array is scanned. ALGORITHMS:-  STEP 1:-    Initialize the required variables. STEP 2:-  Take the input from the user. STEP 3:-   Assume the smallest element is present at the first position. STEP 4:-    Scan each element with the help of for a loop. STEP 5: -    Check if the element Scanned is new smaller than small. STEP 6:-    If it is smallest than small, change the value of small. STEP 7:-    Print small as it stores the smallest element of the array. CODE:- #include <stdio.h> int  main() {      int  a[ 50 ],p,num,smallest;     printf( "Enter the value of num: " );     scanf( "%d" ,&n