Canna

Tuesday, 25 September 2018

LARGEST OF 2 NUMBERS

  • Problem Description

    Find largest of 2 numbers using pointers in c
  • Test Case 1

    Input (stdin)
    23 45
    
    
    Expected Output
    45
  • Test Case 2

    Input (stdin)
    40 30
    
    
    Expected Output
    40
  • Program
  • #include <stdio.h>
    int main()
    {
      int x,y;
      int *a,*b;
      scanf("%d %d",&x,&y);
      a=&x;
      b=&y;
      if(*a>*b)
      {
        printf("%d",*a);
      }
      else
      {
        printf("%d",*b);
      }
      return 0;
    }

No comments:

Post a Comment

Note: only a member of this blog may post a comment.