Saturday, August 18, 2018

BIGGEST VALUE IN A GIVEN ARRAY


  • Problem Description

    Find biggest value in the array using pointers in C
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
      int a[100],n,c,maximum;
      scanf("%d",&n);
      for(c=0;c<n;c++)
        scanf("%d",&a[c]);
      maximum=a[0];
      for(c=1;c<n;c++)
      {
        if(a[c]>maximum)
        {
          maximum=a[c];
          
        }
      }
      printf("%d",maximum);
      return 0;
    }
  • Test Case 1

    Input (stdin)
    2 58 98
    
    
    Expected Output
    98
  • Test Case 2

    Input (stdin)
    3 100 80 10
    
    
    Expected Output
    100

No comments:

Post a Comment