answersLogoWhite

0

How do you print the piramed of stars in c?

Updated: 8/16/2019
User Avatar

Wiki User

13y ago

Best Answer

#include<stdio.h>

int main() {

char prnt = '*';

int i, j, s, nos = 0;

for (i = 9; i >= 1; (i = i - 2)) {

for (s = nos; s >= 1; s--) {

printf(" ");

}

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

if ((i % 2) != 0 && (j % 2) != 0) {

printf("%2c", prnt);

} else {

printf(" ");

}

}

printf("\n");

nos++;

}

nos = 3;

for (i = 3; i <= 9; (i = i + 2)) {

for (s = nos; s >= 1; s--) {

printf(" ");

}

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

if ((i % 2) != 0 && (j % 2) != 0) {

printf("%2c", prnt);

} else {

printf(" ");

}

}

nos--;

printf("\n");

}

return 0;

}

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

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

Write a C plus plus function that print a triangle of stars?

Write a function that print a triangle of stars.


How do you print a triangle of stars?

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


Write a for loop in C to print the 7 stars row?

... int i; for( i = 0; i &lt; 7; ++i ) { printf("*"); } printf("\n"); ...


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.


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.


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); }


How do you print two slashes - right after another - in c?

You will have to use "printf" when you want to print two slashes one after another in c.


Programme in basic to sum of first 10 numbers?

If you wish to sum every number as you go along:10 LET A=120 PRINT A30 LET B=A+140 PRINT A+B50 LET C=B+160 PRINT A+B+C70 LET D=C+180 PRINT A+B+C+D90 LET E=D+1100 PRINT A+B+C+D+E110 LET F=E+1120 PRINT A+B+C+D+E+F130 LET G=F+1140 PRINT A+B+C+D+E+F+G150 LET H=G+1160 PRINT A+B+C+D+E+F+G+H170 LET I=H+1180 PRINT A+B+C+D+E+F+G+H+I180 LET J=I+1190 PRINT A+B+C+D+E+F+G+H+I+J200 STOP


What does a c in a circle mean on a print?

Copyright


How can print bhawana in c?

printf"Bhawana"


Pictures of nautical stars to print out?

See related link for a star map