Sunday, July 29, 2012

Print N numbers without using Loops

In some interviews we may get a question like print certain numbers without using any loops. There are many approaches to accomplish this task. Here i am giving  two of the approaches

1) With recursion 
2) With goto statement.

With Recursion

 void PrintWithRecursion(int fromNumber, int toNumber)
        {
            if (fromNumber <= toNumber)
            {
                Console.Write(fromNumber + " ");
                fromNumber++;
                PrintWithRecursion(fromNumber, toNumber);
            }
        }

With goto statement

void PrintWithGoto(int fromNumber, int toNumber)
        {
        Repeat:
            if (fromNumber <= toNumber)
            {
                Console.Write(fromNumber + " ");
                fromNumber++;
                goto Repeat;
            }
            Console.Read();
        }


Complete Source code:


output:





Thursday, June 14, 2012

Unlocker - System Utility

1) In PC, When we try to access a file or folder, some times we may get few annoying messages like below,

Cannot delete file: Access is denied
There has been a sharing violation.
The source or destination file may be in use.
The file is in use by another program or user.
Make sure the disk is not full or write-protected and that the file is not currently in use.

So, what is the main problem here, why we are unable to access these files or folders?
  Answer is these files/folders may be Locked.

To resolve these kind of issues, we have one handy utility : Unlocker,using which we can identify whether a file/folder has been locked or not, and can unlock the them.

Unlocker is an explorer extension. Once we finish with downloading and installation of Unlocker, all we need to is just right click on any of the file or folder (which we are unable to access) and select the unlocker option.

Then if the folder/file is locked, a window listing of lockers will appear.
Then we can take an appropriate action on that.
                                                     
           
  Thank you Rajesh Devabakthuni for letting me know about this utility.:)