Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program to print triangle of numbers and take number value from user

Posted By: Nettie Day     Category: C Programming     Views: 7952

WRITE A PROGRAM TO GENERATE FOLLOWING FIGURE OF N LINES.
INPUT N FROM KEYBOARD.

1
1 2
1 2 3
1 2 3 4

Code for Program to print triangle of numbers and take number value from user in C Programming

#include<stdio.h>
#include<conio.h>
void main()
{
        int i,n,j;
        clrscr();
        printf("\n Please Give The Value of N:  ");
        scanf("%d",&n);
        for(i=1;i<=n;i++)
    {
            for(j=1;j<=i;j++)
            printf("%d  ",j);
            printf("\n");
    }
        
           getch();
}



****************************** OUTPUT *********************************



     Please Give The Value of N:  5


    1
    1  2
    1  2  3
    1  2  3  4
    1  2  3  4  5



************************************************************************
  
Share: 



Nettie Day
Nettie Day author of Program to print triangle of numbers and take number value from user is from Los Angeles, United States.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!