C++ Online Compiler
Example: Birthday Cake Candles Hackerrank Solution in C++ Programming
C
C++
C#
Java
Python
PHP
main.cpp
STDIN
Run
// Birthday Cake Candles Hackerrank Solution in C++ Programming #include <iostream> #include <cmath> using namespace std; int main() { int s=0; cout << "Enter the size of the array::\n"; cin >> s; int candles[s]; cout << "\nEnter the " << s << " elements of the array::\n"; int i=0; while (i<s) { cin >> 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 cout << "\nTALLEST CANDLES:: " << counter; return 0; }
5 2 5 1 3 5
Output
Clear
ADVERTISEMENTS