Advertisement
Yousuf1791

PHP Programing task

Nov 30th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.19 KB | None | 0 0
  1. //1-100 পর্যন্ত যোগ করার প্রোগ্রাম
  2.  
  3. <?php
  4.  
  5. $sum = 0;
  6. for ($i=1; $i <=100 ; $i++) {
  7.     $sum += $i;
  8. }
  9.  
  10. echo "Sum from 1-100 is $sum";
  11.  
  12. ?>
  13.  
  14. //100-1 পর্যন্ত যোগ করার প্রোগ্রাম
  15. <?php
  16.  
  17. $sum = 0;
  18.  
  19. for ($i=100; $i >= 1 ; $i--) {
  20.     $sum += $i;
  21. }
  22.  
  23. echo "Sum from 100 to 1 is $sum";
  24.  
  25. ?>
  26.  
  27.  
  28. //1-1000 পর্যন্ত জোড় সংখ্যা
  29. <?php
  30.  
  31. for ($i=1; $i <= 1000 ; $i++) {
  32.     if ($i % 2 == 0) {
  33.         echo "$i <br>";
  34.     }
  35. }
  36.  
  37. ?>
  38.  
  39.  
  40. //1-1000 পর্যন্ত বিজোড় সংখ্যা
  41. <?php
  42.  
  43. for ($i=1; $i <= 1000 ; $i++) {
  44.     if ($i % 2 == 0) {
  45.        
  46.     }else{
  47.         echo "$i<br>";
  48.     }
  49. }
  50.  
  51. ?>
  52.  
  53.  
  54. //factorial number বের করার প্রোগ্রাম
  55. <?php
  56.  
  57. function factNum($n){
  58.     if (!is_numeric($n)) {
  59.         return;
  60.     }
  61.  
  62.     $factorial = 1;
  63.     if ($n == 0) {
  64.         return $factorial;
  65.     }
  66.  
  67.     for ($i=$n; $i >= 1 ; $i--) {
  68.         $factorial = $factorial * $i;
  69.     }
  70.     return $factorial;
  71. }
  72.  
  73. $num = 5;
  74.  
  75. echo "The factorial number of $num = ". factNum($num);
  76.  
  77. ?>
  78.  
  79. //Prime number বের করার প্রোগ্রাম
  80. <?php
  81.  
  82. $a = "";
  83. for ($i=2; $i <=100 ; $i++) {
  84.     $isPrime = true;
  85.     for ($j=2; $j <= $i-1 ; $j++) {
  86.         if ($i % $j == 0) {
  87.             $isPrime = false;
  88.         }
  89.     }
  90.     if ($isPrime == true) {
  91.         echo "$i ";
  92.         $a .= "'$i '";
  93.     }
  94. }
  95.  
  96. echo "<br>The number of Prime numbers from 1-100 is ". str_word_count($a);
  97.  
  98. ?>
  99.  
  100.  
  101. //ত্রিভুজের ক্ষেত্রফল বের করার প্রোগ্রাম
  102. <?php
  103.  
  104. $base = 15;
  105. $height = 37;
  106.  
  107. function area_of_triangle($b, $h){
  108.  
  109.     $area_of_triangle = (1/2)*($b*$h);
  110.     return $area_of_triangle;
  111. }
  112.  
  113. echo "Area with $base meter base and $height meter height =". area_of_triangle($base, $height);
  114.  
  115. ?>
  116.  
  117.  
  118. //3 টা সংখ্যার ভিতর বড় সংখ্যা বের করার প্রোগ্রাম
  119. <?php
  120.  
  121. $a = 5;
  122. $b = 9;
  123. $c = 3;
  124.  
  125. if ($a>$b && $a>$c) {
  126.     echo "The highest number is $a";
  127. }elseif ($b>$a && $b>$c) {
  128.     echo "The highest number is $b";
  129. }elseif ($c>$a && $c>$b) {
  130.     echo "The highest number is $c";
  131. }else{
  132.    
  133. }
  134.  
  135. ?>
  136.  
  137.  
  138.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement