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.Test Case 1
Input (stdin)8 1
Expected Output8 7 6 5 4 3 2 1
Test Case 2
Input (stdin)9 9
Expected OutputNo Number
Program
#include <stdio.h> #include<math.h> int main() { int a,b; scanf("%d",&a); scanf("%d",&b); if(a>b) { while(a>=b) { printf("%d ",a); a--; } } else { { printf("No Number"); a++; } } return 0; }
No comments:
Post a Comment
Note: only a member of this blog may post a comment.