Write a C function to generate the following figure for n = 4. 1 1 3 1 3 5 1 3 5 7 The value of n is passed to the function as an argument.

#include<stdio.h>

void design(int n)
{
     int i,j;
     for(i=1;i<=n;i++)
     {
        for(j=1;j<=i;j++)
        {
           printf("%d ",2*j-1);
        }
        printf("\n");
     }
}

main()
{
     design(4);
}

1 comment:

  1. Write a ‘c’ function to generate the following figure for n=7 .. .FOR n 7

    #include

    void design(int n)
    {
    int i,j;
    for(i=1;i<=n;i++)
    {
    for(j=1;j<=i;j++)
    {
    printf("%d ",2*j-1);
    }
    printf("\n");
    }
    }

    main()
    {
    design(7);
    }

    ReplyDelete