Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Write a program to increment IP address to +10 and verify it is correct ip or not ??
example my ip is 172.122.132.143 increment this ip to +10 and verify it is valid ip or not



Write a program to increment IP address to +10 and verify it is correct ip or not ?? example my ip ..

Answer / thiru

set ip "10.255.255.255"
set list [split $ip "."]
set oct1 [lindex $list 0]
set oct2 [lindex $list 1]
set oct3 [lindex $list 2]
set oct4 [lindex $list 3]

if {$oct4>254} {
set oct4 0
set oct3 [expr $oct3+10]
if {$oct3>255} {
set oct3 0
set oct3 [expr $oct3+10]
if {$oct2>255} {
set oct2 0
set oct3 [expr $oct1+10] }
if {$oct1>255} {
set oct1 0
}}} else {
set oct4 [expr $oct4+10]
}
puts "$oct1.$oct2.$oct3.$oct4"

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Tcl Interview Questions

How TCL works

1 Answers   Cisco,


if i give in numbers output should be in characters example : set a 23 o/p twentythree

1 Answers   Alcatel,


WHAT IS TCL?

4 Answers   Airtel,


how to remote log in to a system A to system B ,execute commands in it and collect the log in system A from B using TCL script??  

1 Answers   Global Edge, Sandvine,


Set ip address as 10.30.20.1 write a script to replace the 30 with 40 ?

9 Answers  


How to Swap 30 & 40 in IP address 192.30.40.1 using TCL script?

8 Answers   HCL, ONGC,


 write a regular expressions to fetch all the valid ip's

3 Answers   Alcatel,


Where can find the sample tcl programs?

3 Answers  


Test case on windows calculator?

2 Answers  


How increment a character? For example, I give 'a' and I should get 'b'.

3 Answers  


Hi all, Is there any certification exams available for TCL and Perl. If so please let me know, my mailid is vpbharathi@gmail.com. Thanks in advance, Bharathi.P

1 Answers  


How to get the next ip for given ip ex: 10.10.10.1 -> 10.10.10.2 ex: 10.10.10.255 -> 10.10.11.0

5 Answers   Cisco, HCL,


Categories