answersLogoWhite

0

How do you print a pyramid in c?

Updated: 8/11/2023
User Avatar

Wiki User

11y ago

Best Answer

#include<stdio.h>

void main()

{

int i,j,k,n;

printf("Enter the value of n: ");

scanf("%d",&n);

for(i=1;i<=n;i++)

{

for(k=1;k<=n-i;k++)

printf(" ");

for(j=1;j<=2*i-1;j++)

{

printf("*");

}

printf("\n");

}

}

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

it so simple

#include<stdio.h>

#include<conio.h>

main()

{

int i,j ,n;

clrscr();

printf("enter the any no");

scanf("%d",&n);

for(i=1;i<=n;i++)

{

for(j=1;j<=i;j++)

{

printf("*");

}

printf("\n");

}

getch();

}

any another quary mail me on mohd.yameen786.@Yahoo.com

This answer is:
User Avatar

User Avatar

Wiki User

11y ago

Sample code is as follows:

#include <stdio.h>

void main()

{

int i = 0, j = 0, k =0;

int p_size = 0, dummy = 0;

printf("Exter the Size of Pyramid \n");

scanf("%d", &p_size);

dummy = p_size;

for(i = 0; i < dummy; i++)

{

printf("\n");

for(j = 0; j < p_size ; j++)

printf(" ");

for(k = 0; k < i; k++)

printf("%d ",i);

p_size--;

}

}

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you print a pyramid in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write a c program to print the following pyramid 1 121 1231 12321 1234321?

123454321


What is the use of print option in c plus plus?

C++ has no print option. The print option in your IDE allows you to print your C++ source code, thus giving you a "hard" copy of your code.


Which teotihuacan pyramid faces the sunset on August 12?

C. Pyramid of the Sun


Where was the first pyramid built and who was it bult for?

The first pyramid was the stepped pyramid of Zoser. It can be seen in Saqqara, Egypt. It was built c.4770 years ago. The first smooth-faced pyramid was built for Snefru in c. 2620BC.


When was the earliest pyramid made?

The earliest known Pyramid is the step pyramid at Saqarra built for the pharaoh Djoser c.2600BC


The first pyramid name?

The Step Pyramid of king Djoser c.2900BC at Saqqara


How do you program pyramid of letters using dev c plus programming?

#includeint main(){static int ROWS = 6;char ch;printf("Please enter an UPPERCASE letter:");scanf("%c",&ch);for( int row = 0; row < ROWS; ++row ){// Print padding.for( int column = 1; column < ROWS - row; ++column)printf(" ");// Print letters left of centre.for( int letter = row; letter >= 1; --letter)printf("%c", ch);// Print centre letter.printf("%c", ch);// print letters right of centre.for( int letter = row; letter >= 1; --letter)printf("%c", ch);printf("\n");}return( 0 );}


What is a Type c photograph?

A C-print or Type C-print is a color print from a color negative. The term "Type C" is generally used to distinguish from R or Reversal prints or direct positive prints from transparencies (color positives). Type C prints can also be made digitally. Type C is probably the most common form of color print.


Was the pyramid of Giza the first pyramid to be built in Giza?

No it was not the first pyramid was the Step Pyramid of the 3rd dynasty Pharaoh Djoser built c.2650BC at Saqqara.


How do you print a triangle of stars?

write a c++ programe to print a triangle without (for)


How do you print in c?

printf(format_string, ...);


C program to find greatest of three numbers?

# include&lt;stdio.h&gt; main() { int a,b,c; print f("enter the values of a,b,c"); scan f("%d%d%d",&amp;a,&amp;b,&amp;c); if((a&gt;b)&amp;&amp;(a&gt;c)) print f("Greatest value is a =%d",a); else if((b&gt;a)&amp;&amp;(b&gt;c)) print f("Greatest value is b=%d",b); else print f("Greatest value is c=%d",c); }