**(HackerRank) Write a Modular C Programming code to solve Brother’s Birthday Candles, You are in charge of the cake for your brother’s birthday and have decided on the cake**

You are in charge of the cake for your brother’s birthday and have decided the cake will have one candle for each year of his total age. When he blows out the candles, he’ll only be able to blow out the tallest ones. Your task is to find out how many candles he can successfully blow out.

For example, if your brother is turning 5 years old, and the cake will have 5 candles of height 7, 6, 4, 7, 3, he will be able to blow out 2 candles successfully, since the tallest candles are of height 7 and there are 2 such candles.

**Input Format**

Read N – number of candles.

Read height of each candle.

**Constraints**

N should be positive.

height of candles should be stored in one dimensional array.

**Output Format**

Height of all candles.

Tallest candle.

Count of tallest candles blown.

**Sample Input 0**

```
5
7 6 4 7 3
```

**Sample Output 0**

```
7 6 4 7 3
Tallest Candle = 7
Tallest Candles blown = 2
```

**Sample Input 1**

```
-5
```

**Sample Output 1**

```
Invalid input.
```

**Sample Input 2**

```
10
6 7 9 4 8 4 9 5 9 8
```

**Sample Output 2**

```
6 7 9 4 8 4 9 5 9 8
Tallest Candle = 9
Tallest Candles blown = 3
```

**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[30],int n) { int i; for(i=0;i<n;i++) { scanf("%d",&a[i]); } } void max_count(int a[30],int n) { int i,max=0,count=0; for(i=0;i<n;i++) { printf("%d ",a[i]); if(a[i]>max) { max=a[i]; } } for(i=0;i<n;i++) { if(a[i]==max) { count++; } } printf("\nTallest Candle = %d\n",max); printf("Tallest Candles blown = %d\n",count); } int main() { int a[30],n; scanf("%d",&n); if(n>0) { read(a,n); max_count(a,n); } else { printf("Invalid input.\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) 5 7 6 4 7 3 Your Output (stdout) 7 6 4 7 3 Tallest Candle = 7 Tallest Candles blown = 2 Expected Output 7 6 4 7 3 Tallest Candle = 7 Tallest Candles blown = 2

**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:**