Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Sunday, 5 June 2016

PROBLEM 19:

Write a C program that prints an equilateral triangle for a given n.
For n=3
*
**
***
**
*
For n=4
*
**
***
****
***
**

*
CODE:

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

}

Program Output:







For more problems click here

No comments:

Post a Comment