Unix/Linux Go Back    


Homework & Coursework Questions Students must use and complete the template provided. If you don't, your post may be deleted! Special homework rules apply here.

Multiplication Table in UNIX

Homework & Coursework Questions


Tags
multiplication, scripting, shell, table, unix

Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 07-13-2016
larkha larkha is offline
Registered User
 
Join Date: Jul 2016
Last Activity: 17 July 2016, 9:32 PM EDT
Posts: 1
Thanks: 1
Thanked 0 Times in 0 Posts
Multiplication Table in UNIX

How can I produce this kind of output?

Enter a number: 3
MULTIPLICATION TABLE:

0 1 2 3
1 1 2 3
2 2 4 6
3 3 6 9

When you enter a number, it should show you the corresponding multiplication table. Plus we need to use for loops that I do not actually know. Thanks in advance! Here is my code

#!/bin/bash
echo Enter a number:
read num
iter=1
while [ $num –le 5 ]
do
res=`expr $num \* $iter`
echo $num “*” $iter “=” $res
iter=`expr $iter + 1`
done
Sponsored Links
    #2  
Old Unix and Linux 07-13-2016
DukeNuke2's Unix or Linux Image
DukeNuke2 DukeNuke2 is offline Forum Staff  
Soulman
 
Join Date: Jul 2006
Last Activity: 22 July 2017, 9:38 AM EDT
Location: Berlin, Germany
Posts: 5,693
Thanks: 72
Thanked 300 Times in 287 Posts
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
Sponsored Links
    #3  
Old Unix and Linux 07-13-2016
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 22 July 2017, 7:00 AM EDT
Location: Aachen, Germany
Posts: 11,057
Thanks: 284
Thanked 3,408 Times in 3,138 Posts
Fill in the entire questionnaire compulsory for homework (see rules).
The Following User Says Thank You to RudiC For This Useful Post:
larkha (07-14-2016)
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Create a table - very new to unix aj250 UNIX for Dummies Questions & Answers 11 07-19-2010 04:31 PM
Error with "multiplication table" in shell script vinodpaw Shell Programming and Scripting 4 03-22-2010 06:27 AM
nested loop:multiplication table killboy UNIX for Dummies Questions & Answers 1 10-15-2009 11:33 PM
Creating table in Unix mr_manii Shell Programming and Scripting 7 10-01-2009 09:17 AM
how to view symbol table in unix saravanan_nitt Programming 1 02-14-2008 12:02 AM



All times are GMT -4. The time now is 02:47 AM.