Interview Questions.

TCL Interview Questions and Answers

fluid

TCL Interview Questions and Answers

Q1. What is TCL?

Ans: Tcl (Tool Command Language) is a very effective but clean to research dynamic programming language, suitable for a completely extensive variety of makes use of, including internet and laptop applications, networking, management, trying out and lots of more. Open source and commercial enterprise-pleasant, Tcl is a mature but evolving language this is truly pass platform (windows,all flavors of linux,macintosh), effortlessly deployed and highly extensible.

Q2. How TCL Works?

Ans: Tcl takes the Argument as a document and attempt to examine the file. TCL stores the record in memory and reads the document Line through Line and attempt to validate/compile. TCL presents the output and launch the memory.

Q3. How to increment eacl detail in a listing? Eg: incrlist 1 2 three =>2 three 4

Ans:

// it works like incrlist 5 6 7 =>> 6 7 eight

proc incrlist args 

set s zero

foreach s $args 

incr s 1

puts $s

//for listing

proc incrlist list 

set s zero

foreach s $listing 

incr s 1

puts $s

Q4.How to run a package in tcl ?

Ans:  supply <package_name> (or) package deal require <name>

Q5. How increment a man or woman? For instance, I deliver a and I need to get b?

Ans:

L set person "a"

set incremented_char [layout %c [expr [scan $character %c]+1]] places "Character earlier than incrementing '$person' : After incrementing '$incremented_char'"

Q6.How to extract "information" from "ccccccccaaabbbbaaaabbinformationabcaaaaaabbbbbbbccbb" in tcl the usage of a unmarried command?

Ans: 

% set

a "ccccccccaaabbbbaaaabbinformationabcaaaaaabbbbbbbccbb"

ccccccccaaabbbbaaaabbinformationabcaaaaaabbbbbbbccbb

% set b [string trimleft $a "abc"]

informationabcaaaaaabbbbbbbccbb

% set c [string trimright $b "abc"]

information

OR..

% set output [string trimright [string trimleft

$a "abc"] "abc"]

records

%

price

HubSpot Video

 

Q7. How to Swap 30 & 40 in IP deal with 192.30.40.1 the usage of TCL script?

Ans:  There are 3 solutions.

Set a 192.30.Forty.1

set b [ string range $a 3 4 ]

set c [ string range $a 6 7 ]

set d [ string replace $a 3 4 $c ]

set e [ string replace $d 6 7 $b]

places $e

===OR=====

set a 192.30.Forty.1

set b [ split $a .]

set u [lindex $b 0]

set v [lindex $b 3]

set x [lindex $b 1]

set y [lindex $b 2]

set z [join "$u $y $x $v" .]

places $z

====OR====

set ip 192.30.40.1

regexp ([0-9]+.)([0-9]+.)([0-9]+.)([0-9]+) $ip fit 1st second 3rd 4th

append new_ip $1st $third $2nd $4th

places $new_ip

Q8. How do you locate the length of a string with out the usage of string length command in TCL?

Ans: set str "lenghtofthisstring"

set len zero

set list1 [ split $str "" ]

foreach price $list1 

incr len

puts $len

Q9. How to check whether a string is palindrome or no longer the use of TCL script?

Ans: Code for the above pseudo code.Check if it works!!!!!

Gets stdin a

set len [ string length $a ]

set n [ expr $len/2 ]

for  set i 0   $i < $n   incr i 1  

set b [ string index $a $i ]

set c [ expr $len - 1 - $i ]

set d [ string index $a $c ]

if $b != $d 

puts "no longer a palindrome"

exit

 

places "Palindrome"

Q10. Set ip cope with as 10.30.20.1 write a script to replace the 30 with forty?

Ans: right here you could try this in multiple approaches

regsub 30 $records forty a puts $a this will provide you with the replaced string

string update $statistics three four 40 this will also give you the replaced




CFG