Professional Documents
Culture Documents
Assignment 3
Assignment 3
---------------------------------------------------------------------------------------------------------------------
1) Write a C program that prints the first n integral multiples of i on each line for i=1,2,..,m. The
values of n and m should be taken from the user and m, n should be positive such that 0 < (m,
n) < 15. Otherwise, an appropriate error message has to be printed. Also, the user has to be
asked for inputs as long as he/she does not type valid inputs. Each number should occupy a
width of 5 in your display. Also, there should be a space between successive numbers in a
row. (15M)
Example:
Enter m followed by n:22 12
m and n should be positive such that m,n<15. Enter again:12 15
m and n should be positive such that m,n<15. Enter again:-12 4
m and n should be positive such that m,n<15. Enter again:4 7
1 2 3 4 5 6 7
2 4 6 8 10 12 14
3 6 9 12 15 18 21
4 8 12 16 20 24 28
2) Write a C program to determine the number of lower case alphabets, uppercase alphabets,
single-quotes, digits, words, sentences, special characters (which are not mentioned above)
and characters. (Solve this problem using Do-While) (25M)
Example :
Enter the input text
Today's PDS Lab is on Loops. It Contains 1:While 2:For and 3:Do-While.
Number of uppercase letters = 12
Number of lowercase letters = 37
Number of single quotes = 1
Number of special characters = 5
Number of digits = 3
Number of words = 11
Number of sentences = 2
Number of characters = 71
3) Write a C program that calculates the mean and median of the first n prime numbers. The
value of n should be taken from the user interactively. Display the list of prime numbers,
their mean, median and also print a message whether the mean and median are the same.
If they are not the same, then also print a message telling the user the difference between
the mean and the median. (30M)
4) Write a C program to print the following pattern of numbers by giving the number of rows (N)
as input taken from the user and N should be positive such that 0 < N < 10. Otherwise, an
appropriate error message has to be printed. Also, the user has to be asked for the input as
long as he/she does not type valid input. (30M)