ad

Showing posts with label php pattern. Show all posts
Showing posts with label php pattern. Show all posts

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



Friday, March 14, 2025

"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

Thursday, June 6, 2024

php loop to print alphabet pattern V


php  loop  to print alphabet pattern V


php  loop  to print alphabet pattern V

Example :-

<?php
echo "<pre>";
//loop for row
for($row=0;$row<7; $row++){
    //loop for column
    for($col=0;$col<=7;$col++)
    {
        //condition determine print echo '*'
value
       if((($col==1 or $col==5) and $row <5)or
       ($row==6 and $col==3)or ($row==5 and
($col==2 or $col ==4)))  
        echo "*";
                //print condition met
           
           else
            echo "&nbsp;";
        //if condition
           }          
    echo "<br>"; }

echo "</pre>";
?>

php  loop  to print alphabet pattern V

output :-

php  loop  to print alphabet pattern V


Related Post :-

php string operators

css text decoration

inline css in html

Wednesday, June 5, 2024

php loop to print alphabet pattern T


php  loop  to print alphabet pattern T

php  loop  to print alphabet pattern T 













Example :- 


<?php
echo "<pre>";
//loop for row
for($row=0;$row<6; $row++){
    //loop for column
    for($col=0;$col<=7;$col++)
    {
        //condition determine print echo '*'
value
        if($col==3 or ($row==0 and $col>0 and
$col<6))    
                 echo "*";
                //print condition met
           
           else
            echo "&nbsp;";
        //if condition
           }
         
   
    echo "<br>"; }

echo "</pre>";
?>



php  loop  to print alphabet pattern 



Output :-

php program to print alphabet pattern D

   
php program to print alphabet pattern D













php program to print alphabet pattern D




Example :-



<?php
//loop for rows
echo "<pre>";
for($row=0;$row<11; $row++){
//loop for column
    for($col=0;$col<=11;$col++)
    {
//condition to determine print echo '*'
        if($col==1 or (($row==0 or $row==10 )and
        ($col>1 and $col<9)) or ($col==9
and $row !=0 and $row !=10))
        {
                 echo "*";
           }
           else {
            echo "&nbsp;";
           }
    }  
    echo "<br>";
}
echo "</pre>";
?>


php program to print alphabet pattern D

Output :-

php program to print alphabet pattern D


Related Post :- 

php program factorial number program

reset passwored form

Sunday, June 2, 2024

php program to print Alphabet pattern s

 

php program to print Alphabet pattern s

php program to print Alphabet pattern s

Example :-

<?php

for($row=0; $row<7; $row++)
{
       for ($column=0; $column<=7; $column++)
    {
       if((($row==0 or $row==3 or $row==6)
       and $column>1 and $column <5) or
($column==1
    and ($row==1 or $row==2 or $row==6))or
    ($column==5 and ($row==0 or $row==4 or
$row==5)))
       
       
        echo "*" ;  
        else  
        echo "&nbsp; ";
    }
    echo"<br>";
}
?>

 

php program to print Alphabet pattern s

Output :-

php program to print Alphabet pattern s

Related Post :-

javascript arithmetic operators

forgot password form

php program print square number pattern

php program to print Alphabet pattern y

 

php program to print Alphabet pattern y

php program to print Alphabet pattern y

Example :-

<?php

for($row=0; $row<7; $row++)
{
       for ($column=0; $column<=7; $column++)
    {
       if((($column==1 or $column==5)and $row<2)
or
       $row==$column and $column>0 and $column
<4 or($column==4
       and $row ==2 )or (($column==3)and $row>3))
        echo "*";
    else
    echo "&nbsp; ";
    }
    echo "<br>";
}
?>

php program to print Alphabet pattern y

Output :-

php program to print Alphabet pattern y


Related Post :-

javascript email validation

javascript while loop

php program to print hourglass star pattern

php program to print Alphabet pattern Z

 

php program to print Alphabet pattern Z

php program to print Alphabet pattern Z

Example :-

<?php

for($row=0; $row<7; $row++)
{
       for ($column=0; $column<=7; $column++)
    {
        if((($row==0 or $row==6)and $column>=0
        and $column<=6) or $row+$column==6)
        echo "*";
    else
    echo "&nbsp; ";
    }
    echo "<br>";
}
?>

php program to print Alphabet pattern Z

Output :-

php program to print Alphabet pattern Z


Related Post :-

html element tag

html table border

css introduction

php program print diamond number pattern

 

php program print diamond number pattern

php program print diamond number pattern 

Example :-

<?php
echo "<pre>";
for($i=1;$i<8;$i++)
{
    for($j=$i; $j<8;$j++)
    echo "&nbsp;&nbsp;";
for($j=2*$i-1;$j>0;$j--)
echo("&nbsp;1");
echo"<br>";
}
$n =8;
for($i=8;$i>0;$i--){
    for($j=$n-$i;$j>0;$j--)
    echo "&nbsp;&nbsp;";
 for($j=2*$i-1;$j>0;$j--)
 echo ("&nbsp;1");
echo "<br>";

}
echo"</pre>";
?>

php program print diamond number pattern 

Output :-

php program print diamond number pattern
Related Post :-

how to set background image html table

what is the html frame tag

html tag

php program print square number pattern

 
php program print square number pattern

php program print square number pattern 

Example :-

<?php
echo "<pre>";
//define the number of rows
$rows =5;
//loop each row
for($i=1;$i<=$rows;$i++){
echo "&nbsp;&nbsp;";
//loop each colum
for($j=1; $j<=$rows;$j++)
{
    echo $j*$j." ";
}
echo "</br>";
}
echo "</pre>";
?>


php program print square number pattern 

Output :-

php program print square number pattern


Related Post :-

css border property

html datatime picker

html paragraph tag

Wednesday, May 29, 2024

php program to print alphabet pattern I

PHP program to print alphabet pattern I


PHP program to print alphabet pattern I

Example :-

<?php
echo "<pre>";
for ($row = 0; $row < 11; $row++)
  {
for ($col = 0; $col <= 11; $col++) {
        if (($col == 5 and
($row != 0 and $row != 10)) or
(($row == 0 or $row == 10) and
($col > 1 and $col < 9)) or
  ($col == 9 and ($row == 0 or $row
  == 10))) {
            echo "I";
            //only change the echo
            //value "*" than display
            //tha * structure.
        } else {
            echo "&nbsp;";
        }
    }
    echo "<br>";
}
echo "</pre>";
?>
PHP program to print alphabet pattern I

Output :-

php program to print alphabet pattern I


Related  Post :-

php if else statements

php string operators

php program to print inverted left half pyramid pattern

php program to print alphabet pattern N

php program to print alphabet pattern N

php program to print alphabet pattern N

php program to print alphabet pattern N

Example :-

<?php
echo "<pre>";
$j=22;
for ( $row =0; $row <=10; $row++){
    for($col=0;$col<=21; $col++){
        if($col==$j){
            echo "*";
            $j= $j+1;
            }
            if($col==0 OR $col==12 OR $row
==$col-0)
              {  echo"*";
            }
            else {
                echo "&nbsp;";
        }
    }
   
    echo"</br>";
}
echo "</pre>";
?>


php program to print alphabet pattern N

Output :-

php program to print alphabet pattern N


Related  Post :-

php program to print hollo triangle star pattern

program to print inverted pyramid star pattern in php

php program to print alphabet pattern C

PHP Program to print Alphabet Pattern M

PHP Program to print Alphabet Pattern M

PHP Program to print Alphabet Pattern  M

PHP Program to print Alphabet Pattern  M

Example  :-

<?php
echo "<pre>";
$j=22;
for ( $row =0; $row <=10; $row++){
    for($col=0;$col<=22; $col++){
        if($col==$j){
            echo "M";
            $j= $j-1;
            }
            if($col==0 OR $col==22 OR $row
==$col-1)
              {  echo"M";
            }
            else {
                echo "&nbsp;";
        }
    }
   
    echo"</br>";
}
echo "</pre>";
?>


PHP Program to print Alphabet Pattern  M

Output :-

PHP Program to print Alphabet Pattern  M


Related  Post :-

html pre tag

html block and inline element

php program to print heart star pattern