Saturday, August 18, 2018

PRINT 2


  • Problem Description

    Write a C program to print all numbers between a and b ( a and b inclusive) using a while loop.

    Input format:

    Input consists of 2 integers. The first integer corresponds to a and the second integer corresponds to b . Assume a>=b.

    Output format:

    Refer sample input and output for formatting specifications.
  • CODING ARENA
  • #include <stdio.h>
    int main()
    {
      int a,b;
      scanf("%d%d",&a,&b);
      while(b<=a)
      {
        printf("%d\n",a);
        a--;
      }
      return 0;
    }
  • Test Case 1

    Input (stdin)
    10
    
    4
    
    
    Expected Output
    10
    
    9
    
    8
    
    7
    
    6
    
    5
    
    4
  • Test Case 2

    Input (stdin)
    5
    
    1
    
    
    Expected Output
    5
    
    4
    
    3
    
    2
    
    1

No comments:

Post a Comment