C Coding problem 2010

The problem

Write a user-friendly program which accepts a real number in decimal representation as input and then prints the number and the square of the number as output.

That is all! But …

The user-friendliness of the program is to be manifested by implementing some, or all, or more than, the following features in text mode without using any graphical capabilities of C.

1. The program must indicate the specific area in the monitor where the characters of the number are to be inputted by exhibiting a precisely spaced and located rectangle on the monitor within whose area the number is to be inputted. When the program is started the opening window may look as in the following figure:

Enter a real number in box below:

_

(Press F1 for help.)

2. The program must help a potential user by making accidental hitting of inappropriate keys inconsequential. For example, if the user had already inputted a period (that is, a decimal point) any further hit on the period key should have no effect. The ‘+’ (plus) and ‘-‘ (minus) keys should be active only when the cursor is at the left most position in the box.

3. The user should have the freedom to edit the characters within the rectangular area specified. An ordinary user may expect the usual editing features of full screen text editors: Cursor movements to the left and to the left (but not beyond the rectangular area!), backspace, insert, delete, jumping to the beginning and to the end, etc.

4. Facility for exhibiting a help message detailing the editing features available. This could be (but not necessarily) in the classic traditions of the TurboC world! Upon hitting the F1 key at any time before pressing the ENTER key, a colorfully decorated help window may appear. This window is to contain the details of all the editing features implemented. Other relevant material can also be included. The window is to be closed upon hitting any key. The quality of the contents in the help text and also the design of the help window will have a lot of bearing in determining the prizes. Indeed, documentation is an integral part of writing programs.

5. The user must have an option for quitting the program at any time by pressing the Alt+Q key.

OK. That is a long wish-list!

Remarks

We are not expecting a solution with all these features!

We earnestly exhort all programming enthusiasts to submit their solutions even if they were able to implement only a few of the user-friendliness features. The solution with the maximum number of features implemented in the most aesthetical way will win the prizes.

For example, if there are difficulties in drawing rectangles in text mode try a less satisfying method of representing rectangles, say as in the following diagram:

Enter a real number in box below:

+---------------+

| _ |

+---------------+

(Press F1 for help.)

The challenge is to prove that we were wrong in our expectation. The challenge is to explore the logic, to delve into the inner workings of C, and to implement the logic in the most imaginative way, both logically and visually.

Rules and Regulations

1. The code should be prefaced with the following comment lines with the required information:

/*

Name of Participant :

Class in which studying :

Name of College :

Address of College :

Address for communication :

e-mail id :

Contact Phone No. :

Operating system and compiler used :

List of features implemented in this programme

1. Specifying the inputting area by drawing a rectangle

2. Provision to make accidental hitting of inappropriate keys ineffective

3. Editing features

a. Insert a character

b. Delete a character (delete)

c. Left key

d. Right key

etc.

4. Help window

5. Premature quitting

6. Any other innovative feature

*/

2. The programme should be named name.c where ‘name’ is to be replaced by a string of a maximum of eight characters indicating the name of the participant.

3. The programme should be compilable using standard C compilers (Linux/Windows). No other external header files are allowed.

4. The program code should be submitted as an email attachment to

vidya_c_contest2010@vidyaacademy.ac.in

not later than 03.00 p.m. on 25th October 2009.

5. If there are more than one nearly perfect solution five of the participants will be invited to Vidya Academy campus for making an oral chalk-and-duster presentation of their program.

6. While coming for the presentation, the participants should produce a certificate from the head of the department to the effect that the participant is a bona fide student of the affiliated college / university teaching department.

7. The following factors will be considered in awarding the prizes:

i. The logical accuracy of the program; whether the program performs the intended tasks without errors.

ii. The programming style: aesthetics, clarity, documentation, maintainability, etc

iii. The time of receipt of solutions; in case of nearly identical solutions, the one received earlier maybe considered first for a prize

iv. Oral presentation

8. The contestants selected for oral presentations will have to make their own arrangements for travel to Vidya Academy for participating in the oral presentation. The date of the presentation will be communicated to the selected candidates at the earliest.

9. In all matters related to the contest , the decision of the organizing committee will be final.

End of rules and regulations.

Happy Coding !!!