Unix/Linux Go Back    

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

Multiplication Table in UNIX

Homework & Coursework Questions

multiplication, scripting, shell, table, unix

Thread Tools Search this Thread Display Modes
Old Unix and Linux 07-13-2016   -   Original Discussion by larkha
larkha's Unix or Linux Image
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

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

echo Enter a number:
read num
while [ $num –le 5 ]
res=`expr $num \* $iter`
echo $num “*” $iter “=” $res
iter=`expr $iter + 1`
Sponsored Links
Old Unix and Linux 07-13-2016   -   Original Discussion by larkha
DukeNuke2's Unix or Linux Image
DukeNuke2 DukeNuke2 is offline Forum Staff  
Join Date: Jul 2006
Last Activity: 21 May 2018, 11:17 AM EDT
Location: Berlin, Germany
Posts: 5,715
Thanks: 74
Thanked 305 Times in 291 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
Old Unix and Linux 07-13-2016   -   Original Discussion by larkha
RudiC's Unix or Linux Image
RudiC RudiC is offline Forum Staff  
Join Date: Jul 2012
Last Activity: 21 May 2018, 6:55 AM EDT
Location: Aachen, Germany
Posts: 12,716
Thanks: 412
Thanked 3,910 Times in 3,596 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

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 04:34 PM.