0% found this document useful (0 votes)
90 views5 pages

Programming Tasks: Control Structures & Functions

The document outlines various programming tasks involving conditional statements, loops, functions, arrays, and structures. It includes specific exercises such as checking leap years, calculating grades, performing matrix operations, and simulating an ATM system. Each task emphasizes the use of different programming concepts to solve real-world problems.

Uploaded by

Marshmellow
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views5 pages

Programming Tasks: Control Structures & Functions

The document outlines various programming tasks involving conditional statements, loops, functions, arrays, and structures. It includes specific exercises such as checking leap years, calculating grades, performing matrix operations, and simulating an ATM system. Each task emphasizes the use of different programming concepts to solve real-world problems.

Uploaded by

Marshmellow
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

If, else if, else

1. Write a program to check if a given year is a leap year.


2. Take marks of a student in 3 subjects and display the grade based on percentage.
3. Accept a number and check if it is positive, negative, or zero.
4. Input the age of a person and determine their eligibility for voting, driving, or both.
5. Input a triangle's angles and check if it is valid, then classify it (acute, right, obtuse).
6. Input an employee’s salary and assign a bonus based on salary range.
7. Accept three numbers and find the largest using if-else if ladder.
8. Take the temperature and display whether it's cold, moderate, or hot.
9. Input character and check if it is uppercase, lowercase, digit, or symbol.
10. Calculate discount based on purchase amount using multiple if-else conditions.

Switch-case
1. Create a calculator using switch that performs +, –, ×, ÷ based on user input.
2. Input a number (1–7) and print the corresponding day of the week.
3. Accept a grade (A–F) and display remarks using switch.
4. Enter a number (1–12) and print the month name.
5. Menu-driven program: select 1 for area of circle, 2 for rectangle, 3 for triangle.
6. Create a menu for hotel order system using switch case.
7. Simulate traffic light colors (R, Y, G) and display their meaning.
8. Enter a character and identify vowel or consonant using switch.
9. Simple banking system: 1 for deposit, 2 for withdraw, 3 for check balance.
10. Input a digit and print it in words (e.g., 3 → "Three").

Loops
1. Print all prime numbers between 1 to 100.
2. Find the factorial of a number using a loop.
3. Calculate the sum of the digits of an integer.
4. Count and display the number of even and odd digits in a number.
5. Generate multiplication table of a number up to 10.
6. Display Fibonacci series up to n terms.
7. Accept numbers continuously until 0 is entered, then print their sum.
8. Print reverse of a number using loop.
9. Check if a number is palindrome using loop.
10. Calculate power of a number (a^b) using loop without pow().
Nested Loops
1. Print a full pyramid of stars of height n.
2. Generate a multiplication table from 1 to 10 using nested loops.
3. Print a number pattern like:

1
1 2
1 2 3

4. Print a pattern of letters (A, B, C...) in triangle form.


5. Create a number triangle where each row contains repeated row number.
6. Generate a hollow rectangle of stars with nested loops.
7. Create a program to print prime numbers in a 2D table format (5x5).
8. Print multiplication tables of multiple numbers in a grid format.
9. Generate Pascal’s Triangle using nested loops.
10. Print matrix with diagonal and anti-diagonal pattern highlighted.

Functions
1. Write a function to calculate the factorial of a number.
2. Create a function to determine if a number is prime.
3. Make a function to reverse digits of a number.
4. Function to find the greatest among three numbers.
5. Build a calculator using functions for add, subtract, multiply, divide.
6. Function to check if a string is a palindrome.
7. Create a function that returns sum of digits of an integer.
8. Function to count vowels and consonants in a string.
9. Use a function with default arguments to calculate simple interest.
10. Create a function that takes two arrays and returns their element-wise sum.

Arrays
1. Input and display 10 integers in a 1D array.
2. Find the maximum and minimum value in a 1D array.
3. Search for a given number in an array using linear search.
4. Count how many times a number appears in an array.
5. Reverse a 1D array in-place.
6. Input and display a 3x3 matrix.
7. Find row-wise and column-wise sums of a 3x3 matrix.
8. Transpose a 3x3 matrix using another array.
9. Multiply two 2x2 matrices.
10. Sort an array in ascending order using selection or bubble sort.
Task: Student Grading System with Multiple Criteria

Create a program that uses functions and arrays to manage marks for multiple students. Each
student has marks in 5 subjects. Calculate total, average, and assign grades based on average. Also,
determine the top scorer. Use:

 2D arrays to store marks


 Functions for average, grade, and top scorer
 Nested if-else or switch for grading

Task: Matrix Operations Menu

Write a program that offers a menu using switch to perform the following operations on two
matrices:

1. Addition
2. Subtraction
3. Transpose
4. Multiplication
Use functions for each operation and handle invalid dimension errors gracefully.

Task 3: Pattern Generator with User Input

Ask the user to input a character and a height, and generate the following patterns:

1. Left-aligned triangle
2. Right-aligned triangle
3. Centered pyramid
Use nested loops and a function for each pattern. Add input validation using if-else.

Task 4: Frequency Counter Using Functions

Accept a string from the user. Count the frequency of each letter (case-insensitive), store
frequencies in an array, and display characters with the highest frequency. Use:

 A 1D array of size 26
 Multiple helper functions for input, counting, and display

Task 5: ATM Machine Simulation

Simulate a basic ATM system:

 Login with a 4-digit PIN


 Use switch to display a menu: Check Balance, Withdraw, Deposit, Exit
 Maintain balance using global variable
 Add error checking (e.g., insufficient funds, invalid option)
Task 6: Inventory System Using 2D Array

Build a system to store item names and prices for 5 items. Allow:

 Search by item name


 Calculate total cost of selected items
 Apply discount based on total using if-else ladder
Use arrays of strings and float, and multiple functions.

Task 7: Calendar Date Validator

Accept a date in the format DD MM YYYY and check whether it is valid or not. Consider:

 Leap year rules


 Days in each month
Use separate functions for:
 Leap year check
 Days in month
 Date validation

Task 8: Library System Using Structures and Arrays

Create a system that stores info about 5 books (title, author, year, price). Allow:

 Display all books


 Search by title
 Count books before/after a certain year
Use:
 An array of structures
 Functions for search, display, and filter

Task 9: Statistics Calculator

Input n numbers and calculate:

 Mean
 Median
 Mode
Use:
 Arrays
 Sorting
 Loop-based frequency counter
 Separate functions for each statistic

Task 10: Palindromic Prime Checker

Write a program that:


 Accepts a number from the user
 Checks whether it is a prime
 Checks whether it is a palindrome
 Prints a message based on the combination (both, only prime, only palindrome, neither)
Use at least three modular functions: isPrime(), isPalindrome(), and displayResult().

You might also like