Wednesday, April 26, 2006

Windows Command Prompt - 3 Cool Tips

Many times we use windows command prompt for running batch files or simple operations. DOS users still prefer to interact with the systemthrough command (cmd) prompt. Here are 3 cool tips known to very few users.

(1) Give title to the command prompt

By default system gives title something like "C:\WINDOWS\system32\cmd.exe" to the command window. It becomes very confusing when you open multiple command prompts and minimize them. Use the following syntax to give title to every window.

title
like
C:\>title OneSmartClick.com
will override the default title by 'OneSmartClick.com'

(2) Browse command History (Doskey feature) through F7

Hit F7 Key to browse through the command history. To select a specific command by number, hit F9 after hitting F7. You can use Up/Down arrow keys, Home, End, Page Up, Page Down keys for faster browsing. To cancel history window hit Escape key.

(3) Colorize the Command Prompt

If you are running different applications/scripts in different windows, colors help you to identify application/script easily.Use the following command to change background and foreground. (Note : There is NO SPACE between backround and foregroundcolor digits)

color

e.g.
C:\>color 5e

Sets background to 'Purple' and foreground to 'Light Yellow'. Use 'color -help' to check hex digits for colors.

Visit my Windows Batch Programming Page for cool tips

(C) Prashant N Mhatre (OneSmartClick.Com)

IT Interview questions / Tips page

GRE/GMAT/TOFEL/SAT Links

Mechanical, Chemical, Computer, Electrical, Electronics Engineering Page

Tuesday, April 25, 2006

15 Exercises for Learning a new Programming Language

15 Exercises for Learning a new Programming Language by: Prashant N Mhatre

I've working knowledge of a bunch of programming languages but job demands to learn a new language frequently in a short time. Instead of reading hundreds manual/book pages, I quickly read 10-15 pages of tutorial or primer. (As you know google is the best search engine to look for such stuff). I keep printed copy of the language syntax reference card handy. (There are many reference cards available over internet. Type in 'language to learn' + 'reference card' in google.)


First of all, get familiar with Compiler, compiler option, editor shortcuts or integrated
development environment (IDE). Start with a simple 'Hello World' program. Compile it. Use basic functionalities of debugger like setting break points, printing variable values, moving to the next or specific position, stopping debugger etc.


To grasp basics of a new language quickly, here are the exercises I use. Remember some programs may not good for beginners.


(1) Display series of numbers (1,2,3,4, 5....etc) in an infinite loop. The program should quit if someone hits a specific key (Say ESCAPE key).

(2) Fibonacci series, swapping two variables, finding maximum/minimum among a list of numbers.

(3) Accepting series of numbers, strings from keyboard and sorting them ascending, descending order.

(4) Reynolds number is calculated using formula (D*v*rho)/mu Where D = Diameter, V= velocity, rho = density mu = viscosity Write a program that will accept all values in appropriate units (Don't worry about unit conversion) If number is < 2100, display Laminar flow, If it’s between 2100 and 4000 display 'Transient flow' and if more than '4000', display 'Turbulent Flow' (If, else, then...)

(5) Modify the above program such that it will ask for 'Do you want to calculate again (y/n), if you say 'y', it'll again ask the parameters. If 'n', it'll exit. (Do while loop)
While running the program give value mu = 0. See what happens. Does it give 'DIVIDE BY ZERO' error? Does it give 'Segmentation fault..core dump?'. How to handle this situation. Is there something built in the language itself? (Exception Handling)

(6) Scientific calculator supporting addition, subtraction, multiplication, division, square-root, square, cube, sin, cos, tan, Factorial, inverse, modulus

(7) Printing output in different formats (say rounding up to 5 decimal places, truncating after 4 decimal places, padding zeros to the right and left, right and left justification)(Input output operations)

(8) Open a text file and convert it into HTML file. (File operations/Strings)

(9) Time and Date : Get system time and convert it in different formats 'DD-MON-YYYY', 'mm-dd-yyyy', 'dd/mm/yy' etc.

(10) Create files with date and time stamp appended to the name

(11) Input is HTML table, Remove all tags and put data in a comma/tab separated file.

(12) Extract uppercase words from a file, extract unique words

(13) Implement word wrapping feature (Observe how word wrap works in windows 'notepad')

(14) Adding/removing items in the beginning, middle and end of the array.

(15) Are these features supported by your language: Operator overloading, virtual functions, references, pointers etc.

Is there something called 'namespace / package / module' supported by your language? (Name mangling) - Read More on this

About The Author

Prashant N Mhatre

I mainly developed software for Stock Markets and Chemical Instrustries. To learn more about programming, you could refer to the Programming page I maintain.
http://www.onesmartclick.com/programming/programming.html
Also Engineering page
http://www.onesmartclick.com/engineering/engineering.html
prashant_n_mhatre@yahoo.com