C Online Compiler
Example: Birthday Cake Candles Hackerrank Solution in C Programming
C
C++
C#
Java
Python
PHP
main.c
STDIN
Run
// Birthday Cake Candles Hackerrank Solution in C Programming #include <stdio.h> #include <math.h> int main() { int s=0; printf("Enter the size of the array::\n"); scanf("%d", &s); int candles[s]; printf("\nEnter the %d elements of the array::\n", s); int i=0; while (i<s) { scanf("%d", &candles[i]); i++; } // It will calculate the tallest candles from the given array double max=-INFINITY; int l=s, counter=0; while (l--) { if (candles[l] > max) { max=candles[l]; } } l=s; while (l--) { if (candles[l] == max) { counter++; } } // It will print the final output of the program printf("\nTALLEST CANDLES:: %d", counter); return 0; }
6 3 5 1 3 5 7
Output
Clear
ADVERTISEMENTS