AIM:
To write a c program to print triangle of numbers.
ALGORITHM:
Step 1: Start the program.
Step 2: Declare the variables i,j,k,l and n as “int” datatype.
Step 3: Read N numbers of lines in a triangle.
Step 4: Initialize l=1.
Step 5: for i=1,j=n-i to less than or equal to n.
Step 5.1: for k=1, to less than or equal to j print “ ”.
Step 5.2: for k=1, to less than or equal to 1 print “i ”.
Step 5.3: l is incremented by 2.
Step 6: Stop the program.
PROGRAM CODE:
#include<stdio.h>
void main()
{ int i,j,k,l,n; clrscr(); printf("n type n-no of lines in triangle:"); scanf("%d",&n); l=1; for(i=1,j=n-i;i<=n;i++,j--) { for(k=1;k<=j;k++) printf(" "); for(k=1;k<=l;k++) printf(" %d",i); printf("n"); l+=2; } getch();
}
OUTPUT:

RESULT:
Thus the c program to print triangle of numbers is written and executed successfully.


![How to Save the Output of a Command to a File in Linux Terminal [Beginner’s Tip]](https://linuxpunx.com.au/wp-content/uploads/2020/11/how-to-save-the-output-of-a-command-to-a-file-in-linux-terminal-beginners-tip.png)



