Monday, April 28, 2008

Solution to Group 1 problem

I'll be writing in C++ to start with, will graduate to Java or Ruby if need be.

Group 1.

View the problem statement here.


Click the image to view enlarged version.

Its a good practice to use functions to do the calculation part and use the main() only for calling relevant functions and I/O.



Just click on the images for clarity.

Request: Please take the quiz or leave your comment to help me make this site more useful. Thanks

Categories of questions

Most of the questions here will sound very trivial to a typical coder. But I am starting off with easy questions and we will graduate to tougher ones after I receive some feedback.

The questions are divided into 3 categories:-

Group 1. This question is for people who are not able to solve the Group 2 question.
Group 2. This question is for people who know find the Group 1 question too easy and the Group 3 question, too tough.
Group 3. This question is for people who found Group 1 and Group 2 questions easy to solve.

Its a lame, yet common sense way to categorize!

Todays Question: Group 3

Que 1.3> Write a program that finds the sum of the digits of a number, using recursion.

Todays Question: Group 2

Que 1.2> Write a program to find the sum of the digits in a number.

Todays Question: Group 1

Que 1.1> Write a program to add 2 numbers.

So you wanna code huh?

The best way to be a good coder is to write code and learn from other coders better than you.

I will post 1 problem every single day for people who have just started programming. I will post the solution in the night, the same day.

Based on user feedback, I will make the problems tougher or easier. So, do take part in the quiz.