Home Uncategorized Print Numbers Half Pyramid in C

Print Numbers Half Pyramid in C

SHARE


Here we written code for print given triangle pattern with output.

For improvement of your coding skills we give some tasks along with it. If you solve this tasks and send to our email (onlineexamshubteam@gmail.com) with your details. we will display your details(like Name, City, college, photo) in our site.

Task: Write a c program to print n lines of following triangle. Following pattern contains 5 lines.
A
B B
C C C
D D D D
E E E E E

Write a C Program to print numbers half pyramid.
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5

#include<stdio.h>
int main()
{
   int i,j,n;
   printf(“Enter no.of line want : “);
   scanf(“%d”,&n);
   for(i=0;i<n;i++)
   {
      for(j=0;j<=i;j++)
      {
         printf(“%d “,i+1);
      }
      printf(“\n”);
   }
}

Output:

Enter number of lines you want : 7
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
6 6 6 6 6 6
7 7 7 7 7 7 7
Back to the programs list.

Task Achievers

Till now no one is answered.