Search This Blog

Tuesday 2 April 2019

Skill Rack Daily Challenge Solution - 03/04/2019

 Skill Rack

Daily Challenge Solution

Date : 03/04/2019



ProgramID- 8459
Largest to Smallest Integer

The program must accept three integers as the input. The program must print the integers from the largest of the three integers to the smallest of the three integers in decreasing order as the output.

Boundary Condition(s):
1 <= Each integer value <= 10^7

Input Format:
The first line contains three integers separated by a space.

Output Format:
The first line contains integers separated by a space.

Example Input/Output 1:
Input:
6 2 8

Output:
8 7 6 5 4 3 2

Explanation:
The largest number is 8 and the smallest number is 2.
So the integers from 8 to 2 are printed.

Example Input/Output 2:
Input:
60 51 48

Output:
60 59 58 57 56 55 54 53 52 51 50 49 48

Solution :
------------------------------------------------------------------------

#include<stdio.h>
#include <stdlib.h>

int main()
{
    int a,b,c,l,s;
    scanf("%d %d %d",&a,&b,&c);
    if(a>=b&&a>=c)
    {
        l=a;
    }
    else if(b>=a&&b>=c)
    {
        l=b;
    }
    else
    {
        l=c;
    }
    if(a<b&&a<c)
    {
        s=a;
    }
    else if(b<a&&b<c)
    {
        s=b;
    }
    else
    {
        s=c;
    }
   for(int i=l;i>=s;i--)
   {
       printf("%d ",i);
   }
return 0;
}
------------------------------------------------------------------------

No comments:

Post a Comment