Monday, February 15, 2016

C program to print pattern-a

/*=================================================================================
**
**  File Name     : printPattern_a.c
**  Creation Date : Wed 10 Feb 2016 08:04:44 PM IST
**  Last Modified : Mon 15 Feb 2016 04:25:51 AM IST
**  Compoler      : gcc
**  Author        : Manoj Kumar Patra, manojpatra.in@gmail.com
**  Organization  : SCIS, University of Hyderabad, India.
**
**===============================================================================*/

#include<stdio.h>
int main()
{
    printf("\n= = = = = = = = = = Print Pattern = = = = = = = = = =\n");
    int n, i, count, item=1;
    printf("\nEnter the value of n : ");
    scanf("%d",&n);
    printf("\n");
    for(i=0; i<n; i++)
    {
        count=i+1;
        while(count!=0)
        {
            printf("%d\t",item);
            count--;
            item++;
        }
        printf("\n\n");
        item=1;
    }
    printf("= = = = = = = = = = = = = = = = = = = = = = = = = = =\n");
    printf("\n");
}

Output:

= = = = = = = = = = Print Pattern = = = = = = = = = =

Enter the value of n : 5

1   

1    2   

1    2    3   

1    2    3    4   

1    2    3    4    5   

= = = = = = = = = = = = = = = = = = = = = = = = = = =

No comments:

Post a Comment