Write a Modular C Programming code to find out ACM Project, Maximum sound recoded by sensor
A wireless sensor network consists of autonomous sensors scattered in an environment where they monitor conditions such as temperature, sound, and pressure. Samantha is a researcher working on the Amazon Carbon-dioxide Measurement (ACM) project. In this project, a wireless sensor network in the Amazon rainforest gathers environmental information. Samantha observes the information stored in the sound sensor and is interested to know the maximum value of sound recorded on a particular day.
Input Format
The first line is the number of times sound is recorded by the sensor Second line contains values of sound
Constraints
Sound recorded values can be positive or negative
Output Format
Maximum sound recoded by the sensor
Sample Input 0
5
34 62 -35 123 53
Sample Output 0
123
Sample Input 1
0
Sample Output 1
No sound recorded
Refer : C Programming HackerRank all solutions for Loops | Arrays | strings
CODE:
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> int main() { int n,i,a[100]; scanf("%d",&n); if(n>0) { for(i=0;i<n;i++) { scanf("%d",&a[i]); } int max=0; for(i=0;i<n;i++) { if(a[i]>max) { max=a[i]; } } printf("%d",max); } else printf("No sound recorded"); }
OUTPUT
Congratulations, you passed the sample test case. Click the Submit Code button to run your code against all the test cases. Input (stdin) 5 34 62 -35 123 53 Your Output (stdout) 123 Expected Output 123
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