0% found this document useful (0 votes)
13 views5 pages

TCL Assignment-1

Uploaded by

alphaone0502
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views5 pages

TCL Assignment-1

Uploaded by

alphaone0502
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

TCL ASSIGNMENT – 1

OUTPUTS:
1. puts “welcome to pd” batch-3 ERROR (batch 3 is outside the
quotation mark)
puts “welcome” welcome
puts ‘welcome’ ‘welcome’
puts {expr 3 +2} expr 3 +2
2. set myvariable 18 puts $myvariable ERROR (puts should be in next
line or there should be semicolon
after 18)
3. puts [expr 1+6+9] 16
4. set a 3 ERROR (there should be $ in place
puts @a of @)
5. puts “hello \vworld” hello.world
puts “hello \tworld” hello world
puts “hello \rworld” hello
world
puts “hello \nworld” hello

world
6. set myvariable 18 ERROR (there should be square
puts “expr $myvariable+6+9” braces instead of quotation marks)
7. set variableA 10 ERROR
Set {variableB} test
puts $variableA
puts ${variableB}
8. set myvariable “hello world” hello world
puts $myvariable
set myvariable {hello world} hello world
puts $myvariable
9. set variableA “10” “10” - ERROR
puts $variableA (we must add puts $sum to get
set sum [expr $variableA +20] thevalue of sum =30)
10. set variableA “10” 1.1111
Set tcl_precision 5
set result [expr $variableA/9.0]
puts $result
11. set a 21; set b 10;
set c [expr $a+$b]
puts "line1 - value of c is $c\t"
set c [expr $a-$b]
puts "line2 - value of c is $c\v"
set c [expr $a*$b]
puts "line3 - value of c is $c\t"
set c [expr $a/$b]
puts "line4 - value of c is $c\n"
set c [expr $a%$b]
puts "line5 - value of c is $c\c"
set c [expr $a%$b]
puts "line5 - value of c is $c\t"

o/p: line1 - value of c is 31

line2 - value of c is 11

line3 - value of c is 210

line4 - value of c is 2

line5 - value of c is 1c
line5 - value of c is 1
12. set a 50 ; set b 19 ;
set c [expr $a & $b] ; puts “line1 – value of c is $c\n”
set c [expr $a | $b] ; puts “line2 – value of c is $c\n”
set c [expr $a ^ $b] ; puts “line3 – value of c is $c\n”
set c [expr $a << 2] ; puts “line4 – value of c is $c\n”
set c [expr $a >> 2] ; puts “line5 – value of c is $c\n”
o/p: line1 – value of c is 18
line2 – value of c is 51
line3 – value of c is 33
line4 – value of c is 200
line5 – value of c is 12

13. set a 20
Set b 10
Set c 15
Set d 5
Set e [expr [expr $a + $b]*$c/$d]; puts “value of (a+b)*c/d is :$e\n”
Set e [expr[expr [expr $a + $b]*$c]/$d]; puts “value of ((a+b)*c)/d is :$e\n”
Set e [expr [expr $a + $b]*[expr $c/$d]]; puts “value of (a+b)*(c/d) is :$e\n”
Set e [expr $a [expr $b*$c]/$d]; puts “value of a+(b*c)/d is :$e\n”
o/p: value of (a+b)*c/d is :90
value of ((a+b)*c)/d is :90
value of (a+b)*(c/d) is :90
value of a+(b*c)/d is :50
14. set a 5 ERROR (it is not giving a value
puts \$a instead it is giving $a, if we remove
puts \ “there is a lady who’s sure” \ the we get
5
There is a lady who’s sure)
15. puts “the length of guitar is [string length guitar]”
set s guitar
puts “the length of $s is [string length $s]”
O/p: the length of guitar is 6
the length of guitar is 6

16. puts {the length of guitar is [string length guitar]}


set s guitar
puts {the length of $s is [string length $s]}
o/p: the length of guitar is [string length guitar]
the length of $s is [string length $s]

17. set Z “welcome”


set Z_LABLE “to the hotel TAJ”
puts “$Z $Z_LABEL”
puts “\$Z $Z_LABEL”
puts “$Z [string length $Z_LABEL]”
o/p : welcome to the hotel
$z to the hotel
welcome 12

18. set Z “welcome”


set Z_LABLE “to the hotel TAJ”
puts {$Z $Z_LABEL}
puts {\$Z $Z_LABEL}
puts {$Z [string length $Z_LABEL]}
o/p: $z $z_label
\$z $z_label
$z [string length $z_label]

You might also like