C Programming – HackerRank Solution | FIND LOWEST IN ARRAY |

(HackerRank) Write a Modular C Programming code to solve FIND LOWEST IN ARRAY, Develop a modular program in c to find out the lowest element in an array

Develop a modular program in c to find out the lowest element in an array.

Input Format

Read n – number of elements in an array.

Read elements of an array.

Constraints

value of n should be greater than 0.

Output Format

Display the array elements.

Display lowest element in the array.

Sample Input 0

6
34 921 12 53 -45 -3

Sample Output 0

34 921 12 53 -45 -3 
Lowest number in array is -45.

Sample Input 1

-4

Sample Output 1

Array should not be less than 0.

Sample Input 2

3
13 64 1

Sample Output 2

13 64 1 
Lowest number in array is 1.

Refer : C Programming HackerRank all solutions for Loops | Arrays | strings

 

CODE:

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

void read(int a[10], int n)
{
    int i;
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
}
void highest(int a[10],int n)
{
    int i,min=99999999;
    for(i=0;i<n;i++)
    {
        printf("%d ",a[i]);
        if(a[i]<min)
        {
            min=a[i];
        }
    }
    printf("\nLowest number in array is %d.",min);
}

int main() {

    int n,a[10];
    scanf("%d",&n);
    if(n<1)
    {
        printf("Array should not be less than 0.");
        exit(0);
    }
    read(a,n);
    highest(a,n);
    return 0;
}

OUTPUT

Congratulations, you passed the sample test case.

Click the Submit Code button to run your code against all the test cases.

Input (stdin)

6
34 921 12 53 -45 -3
Your Output (stdout)

34 921 12 53 -45 -3 
Lowest number in array is -45.
Expected Output

34 921 12 53 -45 -3 
Lowest number in array is -45.

 

Please find some more codes of Loops, Condition Statements, 1D Arrays, 2D Arrays, Strings, Pointers, Data Structures, Files, Linked lists, MISC, Solved model question papers & Hacker Rank all solutions on the below page:

Top 100+ C Programming codes – KLE Technological University







Leave a Comment

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

Welcome to FactsPrime

Sorry, We have detected that you have activated Ad-Blocker. Please Consider supporting us by disabling your Ad Blocker, It helps us in maintaining this website. To View the content, Please disable adblocker and refresh the page.

Thank You !!!