write a tcl program to print all the numbers from 1 to 100.which is divisible by 4 and skip when its in 70's and 90's.
Question
write a tcl program to print all the numbers from 1 to 100.which is divisible by 4 and skip when its in 70's and 90's.
Solution
Sure, here is a simple Tcl program that prints all numbers from 1 to 100, which are divisible by 4, but skips those in the 70's and 90's:
for {set i 1} {$i <= 100} {incr i} {
if {$i % 4 == 0} {
if {$i >= 70 && $i < 80} {
continue
}
if {$i >= 90 && $i < 100} {
continue
}
puts $i
}
}
Here's how it works:
- The
forloop iterates over the numbers from 1 to 100. - The
ifstatement checks if the current number is divisible by 4. - If the number is in the 70's or 90's, the
continuestatement skips the current iteration and moves to the next number. - If the number is not in the 70's or 90's, it is printed using the
putscommand.
Similar Questions
Write a TCL program to get the numbers in the range (given in arguments) which are only divisible by 3 and 7.
Find the number of times digit (1) is used while writing numbers from 1 to 100.
WAP to print the prime numbers between 1 – 100
How to get a number 100 by using four sevens (7’s) and a one (1)?
1) Program to print first 20 natural numbers.2) Program to print even numbers uptoo 453) Program to print numbers from 1 to 25 along with its sqaures.4) Program to print numbers in counts of 10 upto 200.5) Program to print the following series 105,98,………7 using while loop.6) Program to print twenty whole numbers in reverse order.
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.