Welcome

>>>Welcome to my "CODE BAZAR"
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others
Code marshal
URI online judge
Others

Update ✔✔✔ Upcoming programming book (.pdf) "Programming Contest (data structures and algorithms) by Md. Mahbub Hasan & "Graph Algorithms" by Safayat Asraf "****** Date: 20 March, 2019****Hazrat Ali****

Sunday 30 October 2016

N. Loop

Problem link
https://algo.codemarshal.org/contests/diu-122-fl16-termwork/problems/N

Score: 1

CPU: 1s
Memory: 512MB

Given n, you have to print n to 1.
Suppose n = 5. Then you have to print 5, 4, 3, 2, 1.
Input
You will be given a positive integer n (1<=n<=1000).
Output
You have to print from n to 1 in n lines. Please see the sample i/o for better understanding.

Sample

InputOutput
55 4 3 2 1

Solution

#include<stdio.h>
int main()
{
    int n,i;
    scanf("%d",&n);
    if(n>=1 && n<=1000){
        for(i=n;i>=1;i--){
            printf("%d\n",i);
        }
    }
    return 0;
}

No comments:

Post a Comment