Section 8: Part A: Tutorial Problems For Practice
Section 8: Part A: Tutorial Problems For Practice
Part‐A: Tutorial Problems for Practice
Instructions:
Draw flowchart and or algorithm depicting how to solve each problem in this part.
Submit your work latest by today. Please clearly write your name, roll number and mobile
number on the front page of the sheets.
Create a sub directory named as LabT3 under your home directory.
Give the name of the programs as <R> <T>1.c, <R> <T>2.c, .. etc. for the tutorial problems
problem 1, 2….., respectively. Here <R> implies your Registration No.
Store all the programs under this tutorial part in the directory LabT3
1. Let n, i and sum be int variables. The user enters a positive value of n. Which of the
following program segments prints the largest value of sum?
[Hint: First try to have the answer of your own and then verify your answer by writing
appropriate programs for each statement.]
[Hint: First try to have the answer of your own and then verify your answer by writing
appropriate programs for each statement.]
[Hint: Run the program for the above and try to understand the output.]
Please turn the page….
Part‐B: Assignment Problems
Instructions:
Create a sub directory named as LabA3.
Give the name of the programs as <R> <A2>1.c, <R> <A2>2.c, …, etc. for the tutorial
problems 1, 2….., respectively. Here <R> implies your Registration No.
Store all the programs under this tutorial part in the directory LabA3.
You should upload your programs to the Moodle course web page. Preferably in ZIP form
latest by 12:45 hrs. today only.
1. Read n integers and print the third largest among them. n is input by user. Don’t use any
array.
2. Read any 4 digit number and print the sum of its digits.
1 + x + x2/2! + x3/3! + ….
[Hint: Value of x and n is input by user. Do not use the factorial or power functions available in
math.h]
4. A number is called a perfect number, if the number is equal to the sum of all its positive
divisors except the number itself. For example, 6 = 1 + 2 + 3, 28 = 1 + 2+ 4 + 7 + 14 are
the two perfect numbers. Find and print all the perfect numbers less than or equal to
1000.
5. Read a sequence of integer numbers (terminated by 0) and find the maximum, minimum
and average value of the numbers (excluding 0) that have been entered.
[Hint: You should not use any array to store the number you read from the keyboard.]
[Submit your solutions to Moodle course management system, latest by 12:45 hrs. toady.]