ad

Wednesday, March 19, 2025

Write C Program to Print Inverted Half Pyramid of Stars Pattern

 https://webdesigningtheory.blogspot.com/2025/06/c-program-to-print-alphabet-t-star.html

Write C Program to Print  Inverted Half Pyramid of Stars  Pattern

Example 


#include<stdio.h>
void main ()
{
int i,j,r;
printf("enter the number");

scanf("%d",&r);

for(i=r;i>=1;i--)

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

{

printf("*");

}

printf("\n");

}

return 0;

}



Write C Program to Print  Inverted Half Pyramid of Stars  Pattern

Explain Program

Step :1

#include <stdio.h>

  • standard input-output library, printf() and scanf() function

Step :2

void main()

  • starting point of the program.

Step :3

. int i, j, r;

  • Declares three integer variables:
  • r: the number of rows (input from the user).
  • i: used for the outer loop (rows).
  • j: used for the inner loop (columns/asterisks per row).

Step :4

printf("enter the number");

scanf("%d", &r);

  •  user to enter the number of rows for the triangle.

Step :5

for(i = r; i >= 1; i--)

  • Starts at i = r and decrements to 1.
  • First row has r stars,
  • Second row has r-1 stars,

Step :6

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

{

    printf("*");

}

  • row, prints i number of asterisks (*).
The number of asterisks decreases as i decreases

Step :7

printf("\n");

  •  cursor to the next line after each row of asterisks.

Step :8

return 0;

Write C Program to Print  Inverted Half Pyramid of Stars  Pattern

 Program Output :- 

Write C Program to Print  Inverted Half Pyramid of Stars  Pattern


Related Post :-

number pattern program C

C program print square star pattern

Free online learn C programming course


Tuesday, March 18, 2025

C Program Print Half Pyramid Using Numbers pattern

https://webdesigningtheory.blogspot.com/2025/03/c-program-to-print-inverted-half.html

C Program  Print Half Pyramid Using Numbers pattern

Example 


#include<stdio.h>
void main ()
{
int i,j,r;
printf("enter the number");
scanf("%d",&r);
for(i=1;i<=r;i++)
{
for(j=1;j<=i;j++)
{
printf("%d",j);
}
printf("\n");
}
return 0;

}


C Program  Print Half Pyramid Using Numbers pattern

Explain Program

Step :1

#include<stdio.h>

  • standard input-output header file use printf() and scanf().

Step :2

void main()

  • main function  execution starts.

Step :3

 Variable Declarations

int i, j, r;

  • r: Number of rows for the pattern (user input).
  • i: Controls the outer loop (rows).
  • j: Controls the inner loop (columns/numbers in each row).

Step :4

printf("enter the number");

scanf("%d", &r);

  •  user to enter the number of rows.

Step :5

Outer Loop – Controls the Rows

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

  • Starts 1 and goes up to r.
  • Each iteration print one row of the triangle.

Step :6

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

{

    printf("%d", j);

}

  •  each row i, it prints numbers from 1 to i.

Step :7

printf("\n");

cursor to the next line

Step :8

return 0;

C Program Print Half Pyramid Using Numbers pattern

 Program Output :- 



Number Pattern Program in C


Related Post :-

C Program Print Right Half Number Pyramid Pattern

C Program Print Righ Half Character Pyramid Pattern

c program print square star pattern



Saturday, March 15, 2025

c program for printing Right half pyramid pattern

https://webdesigningtheory.blogspot.com/2025/03/number-pattern-program-in-c.html

 c program for printing Right half pyramid pattern 

Example 


#include<stdio.h>

int main() {
int i,j ,row;
printf("enter the number of row");
scanf("%d",&row);
for(i=1; i<=row; i++)
  {
  for(j=1;j<=i;j++)

{
printf("%d",i);
}
printf("\n");
 }
getch();
}

c program for printing Right half pyramid pattern

Explain Program

Step :1

#include<stdio.h>

  • Standard Input/Output library to use functions  printf() and scanf().

Step :2

int main() {

  • main function where your program starts execution.

Step :3

int i, j, row;

  • Declares three integer variables:
  • i and j for loop counters.
  • row to store the number of rows entered by the user.

Step :4

printf("enter the number of row");

  •  user to enter how many rows they want in the pattern.

Step :5

 scanf("%d", &row);

  •  input and stores it in the variable row.

Step :6

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

  • Outer loop run from 1 .

Step :7

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

  • Inner loop that run from 1 to i.

Step :8

printf ("%d", i);

  • Print the current row number (i) in the same line.

Step :9

printf("\n");

  • Moves the cursor  next line after printing one row of numbers.

Step :10

getch();

c program for printing Right half pyramid pattern

 Program Output :- 

Write C Program to Print  Right Half Right  Pyramid  Pattern

Related Post :-

HTML Multiple quetion MCQ

 C program print Right Half Pyramid Pattern

Friday, March 14, 2025

Write C Program to Print Right Half Character Pyramid Pattern

https://webdesigningtheory.blogspot.com

 Write C Program to Print Half Character Pyramid  Pattern 

Example 


#include<stdio.h>
int main ()

{

int i,j,n;
 printf("enter the no of line");
 
scanf("%d",&n);
 
for(i=1;i<=n;i++)
  {
 
for(j=1;j<=i;j++)
  {
 
printf("%c",(char)(i+64));
  }
 
printf("\n");
  }
   
getch();  

}


Write C Program to Print  Right Half Character Pyramid  Pattern 

Explain Program

Step :1

#include<stdio.h>

  • standard input/output library.
  •  use printf() and scanf() functions.

Step :2

int main()

  • use starting point of your program.

Step :3

. int i, j, n;

  • i – controls the row number
  • j – controls to the numbers of characters printed per row
  • n – stores the number of lines entered by the user

Step :4

printf("enter the no of line");

  •  user to enter the number of lines to print.

Step :5

scanf("%d", &n);

  • number of lines (rows) from the user and stores it in variable n.

Step :6

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

  • Outer loop: runs from 1 to n
  • Each iteration represents one row of the pattern.

Step :7

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

  • Inner loop: runs from 1 to i
  • It controls how many times a character is printed on each row.

Step :8

printf("%c", (char)(i + 64));

      This is the most interesting part!

  •  printing a character, not a number.

Step :9

 printf("\n");

  • After printing one row, move to the next line

 getch();

Write C Program to Print  Right Half Character Pyramid  Pattern  

 Program Output :

Write C Program to Print  Right Half Character Pyramid  Pattern

Related Post :-

"C Program to Display a Star Square Pattern


https://webdesigningtheory.blogspot.com

 "C Program to Display a Star Square Pattern

Example 


#include<stdio.h>
int main()
{
int row,j,nacr();
for(row=1;row<=10 ;row++)
{
for(j=1;j<=15;j++)
{
printf("*");
}
printf("\n");
}
getch();
}


"C Program to Display a Star Square Pattern

Explain Program

Step :1

#include<stdio.h>

  •  Standard Input Output library.

Step :2

int main()

  • Entry point of the C program.

Step :3

int row, j, nacr();

  • This line declares:
  • int row:-> used as outer loop counter.
  • int j:-> used as inner loop counter.
  • nacr(); -> this  function named nacr that returns int and takes unknown parameters.

Step :4

for(row = 1; row <= 10; row++)

  • Outer loop that runs from row = 1 to 10.
  • Controls how many lines will be printed.

Step :5

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

  • Inner loop that prints asterisks on each line.

Step :6

printf("*");

  • Prints one asterisk without a newline.

Step :7

printf("\n");

  • After printing 15 stars, this moves the cursor to the next line.

Step :8

getch();

"C Program to Display a Star Square Pattern

 Program Output :-

C Program  Print  Square Star Pattern