Canna

Tuesday, 25 September 2018

sum the numbers 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

  • Test Case 1

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

    Input (stdin)
    5 6
    
    
    Expected Output
    11
  • Program
  • #include <stdio.h>
    struct sum
    {
      int a,b;
    }s;
    int main()
    {
      int c;
      scanf("%d %d",&s.a,&s.b);
      c=s.a+s.b;
      printf("%d",c);
    
     return 0;
    }

No comments:

Post a Comment

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