Thursday, 28 June 2018

double diognal

#include<stdio.h>
int main()
{
    int i,j,k,n;
    printf("enter the number");
    scanf("%d",&n);
    int a=1,b=20,c=n+1;
    for(i=0;i<n;i++)
    {
        for(j=0;j<=i;j++)
        {
            printf("%d ",a);
            a++;
        }
        for(k=i+1;k<c;k++)
        {
            printf("%d ",b);
            b--;
        }
        printf("\n");
    }
    return 0;
}
output:
enter the number4
1 20 19 18 17
2 3 16 15 14
4 5 6 13 12
7 8 9 10 11

No comments:

Post a Comment

ASP.NET Core: How to implement Azure Active Directory (AAD) Authentication in ASP.NET Core

  In this tutorial, we will implement security for ASP.NET Core Application using Azure Active Directory (AAD).  In this tutorial, I will co...