Knowee
Questions
Features
Study Tools

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 it's in 70's and 90's.

🧐 Not the exact question you are looking for?Go ask a question

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:

  1. The for loop iterates over the numbers from 1 to 100.
  2. The if statement checks if the current number is divisible by 4.
  3. If the number is in the 70's or 90's, the continue statement skips the current iteration and moves to the next number.
  4. If the number is not in the 70's or 90's, it is printed using the puts command.

This problem has been solved

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.

How many numbers are there between 300 and 700 that are divisible by 4?1 point99100101102

If you write down all the numbers from 1 to 100, then how many times do you write 3 ?Options18112021

Build the  generator primes() function so that you fills the n one at a time, and comes back to primes() function until n > 100.

1/1

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.