Canna

Saturday, 15 June 2019

Printing next 5 numbers

  • Problem Description

    A new game was introduced in a school for students of 3 standard, In which the student should tel next
    5 numbers sequence from the telling number. Using union help to the students to solve it.

    Input Method

    Integer ranges from 1 to 999

    Output Method

    Sequence of next 5 numbers

    Mandatory:

    Use union concept
  • Test Case 1

    Input (stdin)
    8
    
    
    Expected Output
    9 10 11 12 13
  • Test Case 2

    Input (stdin)
    6
    
    
    Expected Output
    7 8 9 10 11
  • Program
  • #include <stdio.h>
    union next
    {
      int n;
    };
    int main()
    {
      int i=0;
      union next s;
      scanf("%d",&s.n);
      while(i<5)
      {
        printf(" %d",++s.n);
        ++i;
      }
      return 0;
    }

No comments:

Post a Comment

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