๐Ÿ“œ
B.TECH III YEAR โ€ข II SEMESTER โ€ข R22

Scripting Languages - Lab Manual

Scripting Languages Laboratory โ€ข Program 12 Solution

๐Ÿ“˜ R22 Regulation ๐ŸŽ“ III Year ๐Ÿ“š II Semester ๐Ÿ“œ Scripting Languages ๐Ÿ’Ž Ruby โ€ข TCL โ€ข Perl ๐Ÿงช Lab Program
Aim of Program 12

Write a TCL script that multiplies the numbers from 1 to 10.

โ† All Programs
Solution

Aim:

☛   Write a TCL script that multiplies the numbers from 1 to 10?

Solution :

PROGRAM: (multiplies_nums.tcl)

 
proc multiplyNums {} {
    set product 1

    for {set i 1} {$i <= 10} {incr i} {
        set product [expr {$product * $i}]
    }

    return $product
}

# Call the procedure
set result [multiplyNums]
puts "The product of numbers from 1 to 10 is: $result"



OUTPUT:

 
The product of numbers from 1 to 10 is: 3628800



โ† Back to Scripting Languages Lab Programs ๐Ÿ“š All Lab Manuals