0% found this document useful (0 votes)
30 views

Assignment 3

The document contains 11 programming assignments involving writing Tcl scripts to: 1. Create a number guessing game that randomly picks a secret number between 1-100 for the user to guess until they get it correct. 2. Read an integer from 1-99999 as input and convert it to words or vice versa. 3. Sort a jumbled list of names and numbers using clues to determine the correct matches.

Uploaded by

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

Assignment 3

The document contains 11 programming assignments involving writing Tcl scripts to: 1. Create a number guessing game that randomly picks a secret number between 1-100 for the user to guess until they get it correct. 2. Read an integer from 1-99999 as input and convert it to words or vice versa. 3. Sort a jumbled list of names and numbers using clues to determine the correct matches.

Uploaded by

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

Assignment 3

1. Make a program that will repeatedly ask the user to guess a secret number from 1 to 100 until the
user guesses the secret number. Your program should pick the number at random by using the magical
formula int(1 + rand 100). When the user guesses wrong, the program should respond “Too high” or
“Too low.” If the user enters the word quit or exit, or if the user enters a blank line, the program should
quit. Of course, if the user guesses correctly, the program should quit then as well!

2. Write a tcl program to read...


a. An integer in the range 1 to 99999 as command-line argument and convert and print the value in
words. You should do validity check on the input.
b. Do the reverse as well.

3. You have a file which contains name & number of friends. Somehow it got all jumbled up.

Jumbled file
A →123123
B → 123456
C → 600123
D → 789123

Somehow you recall that A's num starts with 123 but doesn't end with 123. B's num ends with “123”.
C's & D's numbers last 3 digits are same and C's num doesn't start with “123” either. Use given
information to come up with right name and number.

4. Write a TCL script to sort a list without using the lsort function.
[list should contain words not numbers]

5. Write a TCL script to reverse a list without using the lreverse function.

6. Write a TCL script in which there are two procs. The first proc must take a list of elements as an
argument and check if there are any duplicate elements in the list. And the second must delete
duplicate elements from the list.

7. Create a new TCL command called "lincrement" which takes two arguments a list and a value, list
contains N number of integers, all integers should be incremented by the value given in the argument.
The default increament value should be 1 if the value is not mentioned in the argument.

8. Develop a TCL script that sorts lines of the given file in reverse order, so the last line becomes first
and vice-versa. The script must have two command line arguments, the first is an input file name and
the second is an output file name.

9. Write a TCL script that prints the count of all the cells used in the given netlist.
10. Extend the above program to give counts for sub types of cells.
OAI -> 44
NAND -> 8
AOI -> 48
OA -> 42
OR -> 89
AO -> 39
NOR -> 3
AND -> 50
INVXL -> 105
Total Cell -> 428

11. Write a TCL script to find and print the longest word in a text file.

You might also like