Thursday, September 13, 2018

SUM THE NUMBER USING UNION AND STRUCTURES


  • Problem Description

    Kamachi decided to write one program in which she has to get one values using structure concept and another values using union concept, the result should add both values.Help to her to write code. 

    Input Method

    Integer ranges from 1 to 999

    Output Method

    sum of values

  • CODING ARENA
  • #include <stdio.h>
    struct sum
    {
      int a;
      int b;
    };
    int main()
    {
      int s1;
      struct sum s;
      scanf("%d%d",&s.a,&s.b);
      s1=s.a+s.b;
      printf("%d",s1);
      return 0;
    }
  • Test Case 1

    Input (stdin)
    3 4
    
    
    Expected Output
    7
  • Test Case 2

    Input (stdin)
    5 6
    
    
    Expected Output
    11

No comments:

Post a Comment