Saturday, September 22, 2018

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
  • CODING ARENA
  • #include <stdio.h>
    union stu
    {
      int a;
    }s;
    int main()
    {
      int i;
      scanf("%d",&s.a);
      for(i=s.a+1;i<=s.a+5;i++)
        printf("%d ",i);
    return 0;
    }
  • 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

No comments:

Post a Comment