Saturday, September 22, 2018

PRINT 1

  • Problem Description

    Write a C program to print all numbers between a and b ( a and b inclusive) using a for 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,i;
      scanf("%d%d",&a,&b);
      for(i=a;i<=b;i++)
        printf("%d\n",i);
        return 0;
    }
  • Test Case 1

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

    Input (stdin)
    -1
    
    6
    
    
    Expected Output
    -1
    
    0
    
    1
    
    2
    
    3
    
    4
    
    5
    
    6

No comments:

Post a Comment