C 2425 Lab02
C 2425 Lab02
Lab 02
1. Write a program to input integers, the program ends when user input 0. Print the minimum
(different from 0) and maximum number (different from 0) among the input numbers.
Instead of printing just the min and max, also print the number of times they appear in
the input.:
Input: -3 5 -2 9 8 10 5 -1 0 10
Min: -3 (1 time)
Max: 10 (2 times)
2. Write a function to calculate the factorial with given integer n, which satisfies the
following:
if n is odd, F= 1 ∗ 3 ∗ 5 ∗ … ∗ 𝑛
if n is even, F= 2 ∗ 4 ∗ 6 ∗ … ∗ 𝑛
3. Write a Taxi meter program to calculate the taxi fare for a given travel distance.
4. Write a program to input an integer within range 1..7 then print out the corresponding day
of the week. Example: 3 Tuesday
5. Write a program to find wether a character is sonsoneant or vowel (a, e, i, o, u are vowels)
6. Write a function to check if the given number is Amstrong or not (sum of cubes of
individual digits is equal to the number itself)
7. Write a program to check whether a given number is Prime or not. After that, allow the
user to input N numbers and display only the prime ones.
Enter numbers (separated by space): 12 17 19 20 23
Prime numbers: 17, 19, 23
8. Write a program to check whether an given year is leap year or not (leap year when it is
divisable by for and divisible by 100 or 400). Then extend the problem that allow the user
to input a range of years and print all leap years in that range.
Enter start year: 2000
Enter end year: 2024
Leap years: 2000, 2004, 2008, 2012, 2016, 2020, 2024
9. Write a program that inputs an n-digit number then output its n digits from least to most
significant and print the sum of digits:
Input: 132768
Output: 8 6 7 2 3 1
Sum of digits: 27
Input: 12345
Output: 6
Explanation: 1 + 2 + 3 + 4 + 5 = 15 → 1 + 5 = 6