C program to print 1 3 6 10 15 21 28 36 triangular series

Ex: Write a C program to print 1 3 6 10 15 21 28 36 triangular series. How to write a C program to print 1 3 6 10 15 21 28 36 triangular series. C program to print 1 3 6 10 15 21 28 36 triangular series.


Input from user:
Enter the number: 8

Expected output:
1 3 6 10 15 21 28 36






Program:

#include<stdio.h>
void main()
{
int i,no,z=1;
printf("enter the no\n");
scanf("%d",&no);
 printf("1 ");
for(i=2;i<=no;i++)
{
z=z+i;
printf("%d ",z);

}
}

Above program shows the following Output:


C program to print 1 3 6 10 15 21 28 36 triangular series

No comments:

Post a Comment

If you have any doubts, please discuss here...👇