Computer Science, asked by Anonymous, 11 months ago

Program to print below format.
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1


In Php

Answers

Answered by EHSASS
1

★彡 Here is Your Answer 彡★

if(isset($_POST['sub']))

{

  $rows=$_POST['row'];

  for($i=$rows;$i>=1;--$i)

    {

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

        {

           echo $j;

        }

    echo "<br />";

    }

}

?>

<table>

<form method="post" name="frm" action="">

<tr>    <td>Enter Number of rows:</td>    <td><input type="text" name="row" /></td> </tr>

<tr><td></td>      <td><input type="submit" name="sub" /></td> </tr>

</form>

</table>

Ehsass 彡★

Answered by Anonymous
1

Answer:

#include <stdio.h>

int main()

{

int i,j,n;

printf(“Enter the number: ”);

scanf(“%d”,&n);

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

{

printf(“%d ”,i);

if(i%3 == 0 && i != n)

{

j = i + 3;

printf(“\n”);

while(j != i)

{

if(j > n)

{

j--;

}

else

{

printf(“%d ”,j);

j--;

}

}

i = i + 3;

printf(“\n”);

}

}

return 0;

}

I hope that this works! I didn't compile it. Any complaints, please reply me.

Similar questions