Wednesday, 22 February 2017

PRINT 2

QUESTION 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.


TEST CASE 1

INPUT

10
4

OUTPUT

10
9
8
7
6
5
4


TEST CASE 2


INPUT

5
4

OUTPUT

5
4


EXPLANATION :
According to this program we need enter two integer value and we have print a series of numbers with the help of simple while looping statement. ( While loop )


ALGORITHM : 

  • Input the two numbers from the user ( a,b )
  • Run a while loop with the condition a>b ( while (a>b) )
  • Print the value of "a" variable 
  • Reduce the value of a by 1 ( a-- )
SOLUTION : (Please use this as reference only)

CODE

No comments:

Post a Comment