Contact:
sales@biotechnologyforums.com to feature here

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PERL Program - Matrix Addition
#1
print "Enter elements in matrix A of size 3x3: \n";
for($row=0; $row<3 ; $row++) 
{
  for($col=0; $col<3 ; $col++) 
  {
    $A[$row][$col] = <STDIN>;
  }
}

print "Enter elements in matrix B of size 3x3: \n";
for($row=0; $row<3 ; $row++) 
{
  for($col=0; $col<3 ; $col++) 
  {
    $B[$row][$col] = <STDIN>;
  }
}

for($row=0; $row<3 ; $row++) 
{
  for($col=0; $col<3 ; $col++) 
  {
    $C[$row][$col] = $A[$row][$col] + $B[$row][$col] ;
  }
}

print "Sum of the Matrices A+B is : \n";
for($row=0; $row<3 ; $row++) 
{
  for($col=0; $col<3 ; $col++) 
  {
    printf("%3d", $C[$row][$col]);
  }
  print "\n";
}
  

Possibly Related Threads...
Thread
Author
  /  
Last Post
Replies: 0
Views: 629
04-25-2017, 03:18 PM
Last Postbinu
Replies: 0
Views: 529
04-25-2017, 03:13 PM
Last Postbinu
Replies: 0
Views: 412
04-25-2017, 03:04 PM
Last Postbinu
Replies: 0
Views: 625
04-24-2017, 05:46 PM
Last Postbinu
Replies: 0
Views: 445
04-24-2017, 05:38 PM
Last Postbinu



Users browsing this thread:
1 Guest(s)

PERL Program - Matrix Addition00