HackerRank C- Birthday Cake Candles




Complete the function birthdayCakeCandles in the editor below. It must return an integer representing the number of candles she can blow out.

birthdayCakeCandles has the following parameter(s):

ar: an array of integers representing candle heights



  1. #include<stdio.h>
  2. int main()
  3. {
  4. int n,i,max=0,k=0,b=0;
  5. scanf("%d",&n);
  6. int a[n];
  7. for(i=0;i<n;i++)
  8. {
  9. scanf("%d",&a[i]);
  10. }
  11. for(i=0;i<n;i++)
  12. {
  13. if(a[i]>max)
  14. {
  15. max=a[i];
  16. }
  17. }
  18. for(i=0;i<n;i++)
  19. {
  20. if(a[i]==max)
  21. {
  22. k++;
  23. }
  24. }
  25. printf("%d",k);
  26. }
Please click on the like button if it worked

Solution not working or have any suggestions? Please send an email to [email protected]


donate a cup of tea :)


Join Our Facebook Group

Share this solution






codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube