Sponsored Content
Full Discussion: Multiplication Table in UNIX
Homework and Emergencies Homework & Coursework Questions Multiplication Table in UNIX Post 302977146 by larkha on Wednesday 13th of July 2016 08:58:18 AM
Old 07-13-2016
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
 

10 More Discussions You Might Find Interesting

1. Programming

how to view symbol table in unix

hi , How to view the contents of a "c" program symbol table information in unix. (1 Reply)
Discussion started by: saravanan_nitt
1 Replies

2. Shell Programming and Scripting

unix file to oracle table

Hi , Can anyone help me regarding loading a unix file data to oracle database table using shell scripts? I wanted to grep only this data from a spool file sql_test.txt 99 00:00:00:01 but if I use grep I am getting format sql_test.txt 99 rows selected. Elapsed:... (2 Replies)
Discussion started by: ran16
2 Replies

3. Shell Programming and Scripting

Creating table in Unix

Hi All, In a given directory, I need to list the files present in it in the below given format as a table. File name Permission Number of Bytes File Type Telecom1 --w-r-x 1230 Directory Telecom2 ---x---x---x 450 Device file Telecom3 ... (7 Replies)
Discussion started by: mr_manii
7 Replies

4. UNIX for Dummies Questions & Answers

nested loop:multiplication table

I need help to produce output as below 1 2 3 4 5 2 4 6 8 10 3 6 9 12 15 4 8 12 16 20 5 10 15 20 25 my script #!/bin/bash for (( i = 1; i <= 5; ++i )); do echo -n $i for (( j = 1; j <=5; ++j )); do multiply=$(( $i * $j )) done echo $multiply (1 Reply)
Discussion started by: killboy
1 Replies

5. Shell Programming and Scripting

Insert into Oracle table thru UNIX - linux 2.6.9-89

Hi, I am trying to insert a record into a table (say dips_tbl) which resides in Oracle DB through a ksh script. I want to insert records into few of the table columns-not all. I'll give an e.g. for the date column "CREATE_DATE". For that I first execute SQL1="SELECT SYSDATE FROM DUAL" ... (1 Reply)
Discussion started by: dips_ag
1 Replies

6. Shell Programming and Scripting

Error with "multiplication table" in shell script

#!/bin/sh echo Enter the multiplication number required: read number for i in 1 2 3 4 5 6 7 8 9 10 do echo "$number * $i = expr $number \* $i" done I am not getting the output for this multiplication table. (4 Replies)
Discussion started by: vinodpaw
4 Replies

7. UNIX for Dummies Questions & Answers

Create a table - very new to unix

I need to create a simple table of information by grepping several columns from various files and display them all at once with simple headers on top. Can anyone help get me started? I am very new to unix so I really have no idea how to work with this and I appreciate any help I can get! Let me... (11 Replies)
Discussion started by: aj250
11 Replies

8. UNIX for Dummies Questions & Answers

Hash Table like implementation in unix

Hi all, I just downloaded this example from the net. I was looking around for a hash table like implementation in unix when I came across this. ARRAY=( "cow:moo" "dinosaur:roar" "bird:chirp" "bash:rock" ) for animal in ${ARRAY} ; do KEY=${animal%%:*} ... (8 Replies)
Discussion started by: anindyabecs
8 Replies

9. Shell Programming and Scripting

How to sort matrix table in UNIX?

Hello All, i have a file sort.txt with below entries. 1 12 10 16 6 4 20 8 15 i need to sort these entries and the out put should come in a single line. 1 4 6 8 10 12 15 16 20 Can you please help me sort this out? (2 Replies)
Discussion started by: sureshk_85
2 Replies

10. Shell Programming and Scripting

How to lock Oracle table through UNIX?

Hi frndz, Can anyone provide me some input or pseudo code for my req as mentioned below... I am loading 2 files through unix script into oracle table...as i am doing some updates also i am getting an error where both files try to update the table simultaneously and my script fails.. so i... (3 Replies)
Discussion started by: gnnsprapa
3 Replies
Net::DBus::Binding::Iterator(3pm)			User Contributed Perl Documentation			 Net::DBus::Binding::Iterator(3pm)

NAME
Net::DBus::Binding::Iterator - Reading and writing message parameters SYNOPSIS
Creating a new message my $msg = new Net::DBus::Binding::Message::Signal; my $iterator = $msg->iterator; $iterator->append_boolean(1); $iterator->append_byte(123); Reading from a mesage my $msg = ...get it from somewhere... my $iter = $msg->iterator(); my $i = 0; while ($iter->has_next()) { $iter->next(); $i++; if ($i == 1) { my $val = $iter->get_boolean(); } elsif ($i == 2) { my $val = $iter->get_byte(); } } DESCRIPTION
Provides an iterator for reading or writing message fields. This module provides a Perl API to access the dbus_message_iter_XXX methods in the C API. The array and dictionary types are not yet supported, and there are bugs in the Quad support (ie it always returns -1!). METHODS
$res = $iter->has_next() Determines if there are any more fields in the message itertor to be read. Returns a positive value if there are more fields, zero otherwise. $success = $iter->next() Skips the iterator onto the next field in the message. Returns a positive value if the current field pointer was successfully advanced, zero otherwise. my $val = $iter->get_boolean() $iter->append_boolean($val); Read or write a boolean value from/to the message iterator my $val = $iter->get_byte() $iter->append_byte($val); Read or write a single byte value from/to the message iterator. my $val = $iter->get_string() $iter->append_string($val); Read or write a UTF-8 string value from/to the message iterator my $val = $iter->get_object_path() $iter->append_object_path($val); Read or write a UTF-8 string value, whose contents is a valid object path, from/to the message iterator my $val = $iter->get_signature() $iter->append_signature($val); Read or write a UTF-8 string, whose contents is a valid type signature, value from/to the message iterator my $val = $iter->get_int16() $iter->append_int16($val); Read or write a signed 16 bit value from/to the message iterator my $val = $iter->get_uint16() $iter->append_uint16($val); Read or write an unsigned 16 bit value from/to the message iterator my $val = $iter->get_int32() $iter->append_int32($val); Read or write a signed 32 bit value from/to the message iterator my $val = $iter->get_uint32() $iter->append_uint32($val); Read or write an unsigned 32 bit value from/to the message iterator my $val = $iter->get_int64() $iter->append_int64($val); Read or write a signed 64 bit value from/to the message iterator. An error will be raised if this build of Perl does not support 64 bit integers my $val = $iter->get_uint64() $iter->append_uint64($val); Read or write an unsigned 64 bit value from/to the message iterator. An error will be raised if this build of Perl does not support 64 bit integers my $val = $iter->get_double() $iter->append_double($val); Read or write a double precision floating point value from/to the message iterator my $value = $iter->get() my $value = $iter->get($type); Get the current value pointed to by this iterator. If the optional $type parameter is supplied, the wire type will be compared with the desired type & a warning output if their differ. The $type value must be one of the "Net::DBus::Binding::Message::TYPE*" constants. my $hashref = $iter->get_dict() If the iterator currently points to a dictionary value, unmarshalls and returns the value as a hash reference. my $hashref = $iter->get_array() If the iterator currently points to an array value, unmarshalls and returns the value as a array reference. my $hashref = $iter->get_variant() If the iterator currently points to a variant value, unmarshalls and returns the value contained in the variant. my $hashref = $iter->get_struct() If the iterator currently points to an struct value, unmarshalls and returns the value as a array reference. The values in the array correspond to members of the struct. $iter->append($value) $iter->append($value, $type) Appends a value to the message associated with this iterator. The value is marshalled into wire format, according to the following rules. If the $value is an instance of Net::DBus::Binding::Value, the embedded data type is used. If the $type parameter is supplied, that is taken to represent the data type. The type must be one of the "Net::DBus::Binding::Message::TYPE_*" constants. Otherwise, the data type is chosen to be a string, dict or array according to the perl data types SCALAR, HASH or ARRAY. my $type = $iter->guess_type($value) Make a best guess at the on the wire data type to use for marshalling $value. If the value is a hash reference, the dictionary type is returned; if the value is an array reference the array type is returned; otherwise the string type is returned. my $sig = $iter->format_signature($type) Given a data type representation, construct a corresponding signature string $iter->append_array($value, $type) Append an array of values to the message. The $value parameter must be an array reference, whose elements all have the same data type specified by the $type parameter. $iter->append_struct($value, $type) Append a struct to the message. The $value parameter must be an array reference, whose elements correspond to members of the structure. The $type parameter encodes the type of each member of the struct. $iter->append_dict($value, $type) Append a dictionary to the message. The $value parameter must be an hash reference.The $type parameter encodes the type of the key and value of the hash. $iter->append_variant($value) Append a value to the message, encoded as a variant type. The $value can be of any type, however, the variant will be encoded as either a string, dictionary or array according to the rules of the "guess_type" method. my $type = $iter->get_arg_type Retrieves the type code of the value pointing to by this iterator. The returned code will correspond to one of the constants "Net::DBus::Binding::Message::TYPE_*" my $type = $iter->get_element_type If the iterator points to an array, retrieves the type code of array elements. The returned code will correspond to one of the constants "Net::DBus::Binding::Message::TYPE_*" AUTHOR
Daniel P. Berrange COPYRIGHT
Copyright (C) 2004-2011 Daniel P. Berrange SEE ALSO
Net::DBus::Binding::Message perl v5.14.2 2011-06-30 Net::DBus::Binding::Iterator(3pm)
All times are GMT -4. The time now is 06:28 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy