Problem 3 from 52 programming problems book

1st approach:

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int counts=0;
    for(int i=1000; i>=1; i--)
    {
        counts++;
        printf("%d\t",i);
        if(counts%5==0)
        {
            printf("\n");
        }
    }

    return 0;
}

2nd approach:

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{

    for(int i=1000; i>=1; i--)
    {
        if((i!=1000)&&(i%5==0))
        {
             printf("\n");
        }
         printf("%d\t",i);
    }

    return 0;
}

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *