HackerRank C- Breaking the Records




Complete the breakingRecords function in the editor below. It must return an integer array containing the numbers of times she broke her records. Index 0 is for breaking most points records, and index 1 is for breaking least points records.

breakingRecords has the following parameter(s):

scores: an array of integers



  1. #include<stdio.h>
  2. int main()
  3. {
  4. int n;
  5. scanf("%d",&n);
  6. int a[n];
  7. int max=0;
  8. int min=0;
  9. int count=0;
  10. int count1=0;
  11. scanf("%d",&a[0]);
  12. min=a[0];
  13. max=a[0];
  14. for(int i=1;i<n;i++)
  15. {
  16. scanf("%d",&a[i]);
  17. if(max<a[i])
  18. {
  19. max=a[i];
  20. count++;
  21. }
  22. if(min>a[i])
  23. {
  24. min=a[i];
  25. count1++;
  26. }
  27. }
  28. printf("%d %d",count,count1);
  29. }




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