pyramid star pattern in c
1. pyramid star pattern in c
#include <stdio.h>
int main()
{
int n;
printf("Enter the size of n");
scanf("%d",&n);
for(int i=0;i<n;i++)
{
for(int j=0;j<2*n-1;j++)
{
if(j>=n-i-1 && j<n+i)
printf("*");
else
printf(" ");
}
printf("\n");
}
return 0;
}
2. inverted pyramid star pattern in c
#include <stdio.h>
int main()
{
int n;
printf("Enter the size of n\n");
scanf("%d",&n);
for(int i=0;i<n;i++)
{
for(int j=0;j<2*n-1;j++)
{
if(j>=i && j<2*n-i-1)
printf("*");
else
printf(" ");
}
printf("\n");
}
return 0;
}
Output:
3. 180-degree pyramid star pattern in c
#include <stdio.h>
int main()
{
int n;
printf("Enter the size of n\n\n");
scanf("%d",&n);
for(int i=0;i<2*n-1;i++)
{
for(int j=0;j<n;j++)
{
if(i<n)
{
if(j<=i)
printf("*");
}
else
{
if(j<2*n-i-1)
printf("*");
}
}
printf("\n");
}
return 0;
}
6 Comments
Thank you for giving such an informative information; it would be beneficial to both old and new students for improved preparation. I appreciate your efforts in making such a valuable resource available to everyone. C Programming Notes For BCA Students
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteImportant information
ReplyDeleteSwitch case in C
While loop in C
Structure in C
Read these important topics of c
Your post is awesome and so informative for computer science students.
ReplyDeleteif you want news related content so pls visit here ->> Scorpio New Modal
if you want more about information of computer keyboard than click link below
ReplyDeleteWhat is keyboard in computer?
Nice and helpful..
ReplyDeletelearn more C programming examples....
⬇️⬇️⬇️
Loops in C examples
C pattern programming examples
C Arrays examples
if-else in C with examples
Strings in C with examples
and many more..
Post a Comment