Thursday, September 13, 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[50],s,i,l;
      scanf("%d",&s);
      for(i=0;i<s;i++)
        scanf("%d",&a[i]);
      l=a[0];
      for(i=1;i<s;i++)
      {
        if(l<a[i])
          l=a[i];
      }
      printf("%d",l);
      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