This page is an attempt to help you master programming, by taking small steps at a time. We start with something trivial, and work our way up to very difficult problems. Difficulty is, of course, dependent on how much you have experience. So, it is better to go ahead and attempt everything in sequence…. Along with the problems, a few questions/variants are also listed. Try them too — it should deepen your understanding.

- Write a program which prints "Welcome to programming".
- Write a program which asks you for your name ("Please enter your name:"), and then says "Welcome sss, to programming" where sss is replaced with the name you have given.
- In the program, was the prompt and your entry of name on separate lines? Try a single line.
- What was the name of the variable you used to store the name? Is there any restriction on the length of name permitted?

- Write a program which takes two numbers from user ("Please enter number 1", "Please enter number 2"), and prints their sum.
- Can we enter both numbers in one line, separated by space?
- Can we do with a single question?
- Print the numbers and their sum.

- Revise above, to print sum, difference, product and quotient.
- Make the output look clean with proper alignment.

# arrays and sequences ….

- Create a sequence as follows in an array.
- Every element has value k (for a given k). e.g. 3 3 3 3 3 3 3 3
- Random elements within a range (say, 0 to 100, or 0 to 1)
- Sequence in arithmetic progression starting with a0, at interval of r
- Sequence in geometric progression starting with a0, at multiple of r

- For a sequence stored in an array A, do the following
- Compute the minimum value
- Compute the maximum value
- Compute the sum
- Count number of elements greater than x
- Count number of unique elements — with sorting, and without sorting
- Count the longest sub-sequence of ascending values

- For a sequence of elements with only 0 or 1 in them:
- Compute the fraction of 1s over the sequence
- Compute the number of transitions from 0 to 1, and 1 to 0
- Compute the number of sequences of 1s
- Compute the length of the longest sequence of 1s

- For a 2-D matrix of values, do the following
- produce transpose of the matrix
- check if the diagonal elements are all having value 1
- check if the values below the diagonal are all zeros
- check if the values above the diagomal are all zeros

- For a string sequence do the following:
- how many occurrences of a character are there in the string?
- how many occurrences of a substring are there in the string?
- Allow ? as a wildchar in the substring
- Allow * as an open wild char in the substring

# Given a file of text (a report, a document, etc)

- Given a corpus of text (say a web document, or a report) find the probability of a vowel following a consonant. A consonant may be followed by a consonant, a vowel, white space (blanks, newlines, etc), or a punctuation.
- Write a program which reads a file containing text words (for example, this problem statement itself), ignores all punctuation marks, and reports how many words are of various lengths as follows:

length 1: 3

length 2: 24

length 3: 8

etc. "a" is of length 1, "be" is 2, "ant" is 3, and so on. There is no need to remove duplicate words.

- Search for a given string S in the text, and report if it occurs or not. Just yes or no.
- Extend the previous, report how many times it occurs, and the corresponding lines. A match will not span across multiple lines. Look for overlapping matches also.
- Provide for a "?" in S which will match any one character. That is, "a?t" will match ant, amt, awt, etc.

# Validation programs

Here you write functions to check if a given input is valid as given in the respective problem. All functions return zero if input is valid, and some number > 0 in case of failures. The number can be used to identify the error/violation.

- A string consists of only alphabets
- A string consists of only numbers — binary, decimal, hexa?
- A string is a syntactically valid e-mail address
- A sequence of numbers is sorted.
- A sequence of strings is sorted.
- A sequence is nearly sorted.
- Given number is within a given range.

# Specific tasks

#Produce the base-64 representation of a given character string. How easy is it to change the mapping of code to printable-characters?

#Given a pair of linear simultaneous equations, write a program to solve them. The equation ax+by=c, will be given as three floating point numbers a, b, c in one line, for input. The output will be x = …, y = …, if the equation has a unique solution. Else, print a suitable message.