Data Structure Lab(25CS151)
Programs List
1.1 Largest of Three Numbers
Write an Algorithm to input three numbers and determine which
Problem number is the largest among them
Statement
-
Input
Format
Output -
Format
Sample -
Input
Sample -
Output
1.2 Leap Year
Write an Algorithm to check whether the user input year is Leap
Problem year or not.
Statement
-
Input
Format
Output -
Format
Sample -
Input
Sample -
Output
1.3 Sum of digits
Draw a Flow-Chart to display the sum of digits of 4 digits user
Problem input number.
Statement
-
Input
Format
Output -
Format
Sample -
Input
Sample -
Output
2.1 Swapping of two numbers
Write a program to input two numbers and display the numbers
Problem after swapping their values.
Statement
First line of input contains the two integers denoting the
Input
value of a a n d b .
Format
Output Display numbers after swapping in a single line.
Format
Sample 59
Input
Sample 95
Output
2.2 Salary Calculation
Basic salary of an employee is input through the keyboard. The
Problem DA is 25% of the basic salary while the HRA is 15% of the basic
Statement salary. Provident Fund is deducted at the rate of 10% of the
gross salary (BS+DA+HRA). Program to calculate the Net
Salary.
First line of input contain the integers denoting the value
Input
of Basic Salary.
Format
Output Display the Net Salary
Format
Sample 10000
Input
Sample 12600
Output
2.3 Sum of digits
Write a program to input 4-digits number and display the sum of
Problem digits.
Statement
First line of input contain the 4 digits integers
Input
Format
Output Display the sum of digits
Format
Sample 4587
Input
Sample 24
Output
3.1 Largest of Three Numbers
Write a program to input three numbers and determine which
Problem number is the largest among [Link] Ternary Operator
Statement
First line of input contains the three integers denoting the
Input
value of a , b a n d c .
Format
Output Largest integer in a single line.
Format
Sample 592
Input
Sample 9
Output
3.2 Leap Year
Write a program to input a year and check the input year is
Problem leap year or not using ternary Operator.
Statement
First line contains the integer denotaing the year
Input
Format
Output Display the result either Leap year or Not a Leap Year.
Format
2024
Sample
Input
Sample Leap Year
Output
3.3 4 digits Palindrome Number
Write a program to input a 4 digits number and check the input
Problem number is palindrome or not using ternary Operator.
Statement
First line contains the integer denotaing the 4 digits number
Input
Format
Output Display the result either Yes or No.
Format
1331
Sample
Input
Sample Yes
Output
4.1 Calculator
Write a program to input two numbers and one operation
Problem choice([Link], [Link], 3. Multiplication, 4.
Statement Division).Perform the binary operation as per the given choice.
First line contain the integers denotaing the two numbers and
Input operation choice
Format
Output Display the result.
Format
10 20 3
Sample
Input
Sample 200
Output
4.2 Display Fibonacci Series Until N
Problem Generate and display the Fibonacci sequence up to a given
Statement limit.
Input First line contain the single number.
Format
Output Display the series upto given limit.
Format
Sample 50
Input
Sample 0 1 1 2 3 5 8 13 21 34
Output
4.3 Check for Armstrong Number
An Armstrong number of n digits is a number equal to the sum
Problem of its digits raised to the power n.
Statement Find if a number is an Armstrong number or not.
Input First line contais the value of a number.
Format
Output Display the message Yes or Not.
Format
Sample 1634
Input
Sample Yes
Output
5.1 Sum of Digits Until a Single Digit
Find the sum of digits of a number repeatedly until the sum
Problem becomes a single-digit number.
Statement
Input First line contain the number.
Format
Output Display the final single digit.
Format
Sample 9875
Input
Sample 2
Output (Explanation: 9+8+7+5=29 → 2+9=11 → 1+1=2)
5.2 Display All Prime Numbers Between 1 to N
Problem
Statement find and print all prime numbers between 1 and N.
Input First line contain the value of N.
Format
Output Display all space separated prime numbers.
Format
Sample 50
Input
Sample 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47
Output
5.3 Pattern Display
Problem
Statement Display the given pattern for a given number of rows.
Input First line contain the value of N.
Format
Output Display the pattern.
Format
Sample 5
Input
Sample 1
Output 121
12321
1234321
123454321
6.1 Display Top-3 Students
Display the top three students [Link] that n students
Problem marks.
Statement
First line contain the number of students(n).
Input Second line contain the marks of n students
Format
Output Display the top three student marks.
Format
Sample 10
Input 80 87 55 85 82 79 74 95 65 91
Sample 95 91 87
Output
6.2 Binary-Search
Find the location of a given number N in an array whose size
Problem and elements are [Link] elements are stored in an array
Statement are in increasing order.
First line contain the value of N.
Input Second line contain the values of N element.
Format Third line contain the element whose location to be find.
Output Display the location.
Format
6
Sample 10 12 15 18 20 25
Input 18
Sample 4
Output
6.3 Matrix Multiplication
Write a program to multiply two matrices and display the
Problem resultant matrix.
Statement
(Validate that number of columns of A = number of rows of B.)
First line contain the order of two matrix.
Input Second line contain the elements of first matrix.
Format Third line contain the elements of second matrix.
Output Display the resultant matrix.
Format
2333
Sample 111111
Input 111111111
Sample 333
Output 333