Skip to main content

Fifteen Exercises for Learning a new Programming Language

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.

Article written by Prashant N Mhatre.

Comments

Popular posts from this blog

Play against Xbox360 gamer on PC in Vista

Microsoft Corp. co-founder Bill Gates on Tuesday announced a cross-platform gaming service that integrates games played on cell phones, Xbox 360 consoles and the upcoming Windows Vista operating system. The "Live Anywhere" service will be available as part of Windows Vista, Microsoft's next-generation PC operating system. The consumer version is scheduled for release early next year. "It means that you have one online community," Gates said in a news conference. "This platform can really unleash developers to do amazing new things." The system would extend the company's existing Xbox Live service for the Xbox 360 console into millions of Internet-enabled PCs and cellular phones. No pricing information on the new service was announced. In recent months, Microsoft has been pushing a number of online services that it hopes will boost revenue as markets for its traditional software become increasingly saturated. The company expects to make money off s...

Welcome to Google Checkout, that will be $3.14

From ZDNet The first time I looked up the domain " GDrive.com " it appeared that someone other than Google had it registered. A trip down memory lane takes us to my very first article that describes how I determined GDrive.com is in fact owned by Google, despite what it looks like on the surface. Well, by the same logic I have found that a brand new set of domains appearing to be registered to someone else were actually registered by Google on May 25th. The domains googlecheckout.net / org / info (.com is owned by someone else at the moment) have all been registered to a company called DNStination, Inc. Don't be fooled, the registrar is MarkMonitor — a company that prides itself on the protection of your corporate identity. There is no way they would let just anybody register a domain with "Google" in it — especially since Google is one of their clients. Then who is this DNStination, Inc. then? Googling the address of this "company" tell...

Hackers biting Apple

Hackers are increasingly focusing on Apple's Mac OS X, and the number of newly discovered vulnerabilities has surged. Such a switch could mean big implications for Apple's user base, which has traditionally not had to concern itself too much over security. It's been an impressively quiet year so far on the PC virus and worm front, and hackers seem to be focusing their attention elsewhere. One such area is Apple's Mac OS X. Once mostly ignored by malware developers, there appears to be a growing interest in this "alternative" OS. Details Have you noticed the dearth of serious PC virus and worm threats out there lately? Well, it isn't a figment of your imagination -- according to vnunet.com, viruses are no longer the top security threat . While serious attacks are still likely to emerge, the bottom has apparently fallen out of the PC antivirus market -- just as Microsoft begins a big push into the security market. One cause of this drop-off is solidif...