Saturday, June 18, 2022

List of Programs in Python

Select the Menu for the Solved programs

Basic Programs 

General Programs 

Write a program to display the message "Hello World" on to the Screen.

Write a program to display the message "Hello World" in two separate lines on to the Screen.

Write a program to display the message "Hello World" within double quotes.

Write a program to add two number. The numbers are accepted from the user.

Write a program to find the sum and product of two number. The numbers are accepted from the user.

Write a program to accept the length and breadth of a rectangle and find the area and perimeter of the rectangle.

Write a program to find the area and circumference of the circle.

Selection Structure

Write a program to check whether the person is eligible to vote or not.

Write a program to accept the temperature of the day if the temperature >= 40 display "Hot Day" else display "Cold Day"

Write a program to accept the marks of three subjects. If the total>=150 display "Pass" else "Try Hard"

Write a program to accept a number and check whether the number is odd or even.

Write a program to accept a non century year and check whether the leap year or not.

Accept a number and check whether the number is negative, positive and zero.

Accept the cost price and selling price and find out whether he has made profit, loss, no profit no loss.

Accept the weight from the user. If the weight >100 display "Over  Weight" if the weight>=40 display "normal weight" else display "below weight"

Accept the age and display the following message

            Age Remark

            <=12 Child

            <=19 Teenager

            <=35 Youth

            <=60 Adult

            >60 Senior Citizen

Simple Loops


Loops using For Statement

Generate natural number from 1 to 10

Generate odd numbers from 1 to 19

Generate even numbers from 2 to 20

Generate natural numbers from 1 to n

Generate even numbers from 2 to n

Write a program to generate the square series from 1 to n. 1,4,9,16,25...............n^2

Write a program to generate the cube series from 1 to n. 1,8,27,64..........n^3

Generate the series. 0,3,8,15,24,35,48,63 up to nth term

Generate the series . 2,5,10,17,26,37 up to nth term

Generate the series. -1,24,99,224,399,624,899 up to n

Loops Using While Statement

Write a program to generate natural numbers from 1 to n

Generate even numbers from 2 to 20

Write a program to generate the square series from 1 to n. 1,4,9,16,25...............n^2

Write a program to generate the cube series from 1 to n. 1,8,27,64..........n^3

Loops Using Do...While Statement

 

Write a program to generate natural numbers from 1 to n. 

Generate odd numbers from 21 to n

Write a program to generate the square series from 1 to n. 1,4,9,16,25...............n^2

Write a program to generate the cube series from 1 to n

Summation of series

Write a program to find the sum of the series from 1 to n

Write a program to find the sum of the series from 1 to n. s=1/1+1/2+1/3+1/4+1/5.......1/n

Write a program to find the sum of the series from 1 to n. s=1 - 2 + 3 - 4 + 5.......n

Write a program to find the sum of the series from 1 to n. s=a - a/2 + a/3 - a/4 + a/5.......a/n

Write a program to find the sum of the series from 1 to n. s=a - a^2/2 + a^3/3 - a^4/4 + a^5/5.......a^n/n

Programs based on Factorial

Write a program to find the factorial of a given number. For example factorial of 5 = 1x2x3x4x5=120

Write a program to find the sum of the factorials. s=1+2!+3!+4!+5!......n!

            s=1 + 1x2 + 1x2x3 + 1x2x3x4 + 1x2x3x........n!

Write a program to find the sum of the factorials. s=1+1/2!+1/3!+1/4!+1/5!......1/n!

Write a program to find the sum of the factorials. s=1 + 2!/2 + 3!/3 + 4!/4 + 5!/5......n!/n

Programs based on Factors Logic

Write a program to find the factors of a given number

Write a program to count the number of factors of a given number.

Write a program to sum the factors of a given number..

Check whether the given number is prime or not. A prime number is a number which has two factors only. 

Check whether a given number is a perfect number or not. A perfect number is a number whose factors less than the number added together gives the number. For example 6 is a perfect number because the factors 1+2+3=6.

Twin primes are pairs of prime numbers with a difference of two. The first twin Prime Numbers are {3,5}, {5,7}, {11,13}, and {17,19}. Write a program to accept two numbers form the user and check whether they are twin prime numbers or not.

The Twisted Prime number is a special prime number which is also known as the Emirp number. A number is a twisted prime number if the reverse of the number is also a prime number. 79 is a twisted prime number because after reversing it, we get 97.

Write a program to find the Highest and Lowest common factors of two given numbers.


Programs based on Individual Digits


Write a program to accept a number and find the sum of the individual digits of a given number.

Write a program to accept a number and reverse a given number.

A palindromic number (also known as a numeral palindrome or a numeric palindrome) is a number (such as 12321) that remains the same when its digits are reversed.Write a program to accept a number and  check whether the number is palindromic number or not.

An Armstrong number, also known as narcissistic number, is a number that is equal to the sum of the cubes of its own digits. For example, 153 is an Armstrong number since 153 = 1*1*1 + 5*5*5 + 3*3*3. Write a program to accept a number and check whether the number is Armstrong number or not.

Write a program to accept a number and  check whether the number is spy number or not.

If the sum of the factorial of digits of a number (N) is equal to the number itself, the number (N) is called a special number. For example 145 = 1! + 4! + 5!. Write a program to accept a number and check whether the  number is a special number or not. Sum of the factorial of the individual digit is equal to the number.

A neon number is a number where the sum of digits of square of the number is equal to the number. Write a program to accept a number and check whether the number is neon number or not.

Nested Loop in C 

 

Programs based on different patterns

Generate all prime numbers between 1 to 100

Generate all twin prime numbers between 1 to 100

Generate all Armstrong numbers between 1 to 1000

 

Single Dimensional Array in C

Write a program to accept 5 elements in the array and display the same.

Write a program to accept 10 elements in the array and display the first five elements of the array.

Write a program to accept 10 elements in the array and display the last five elements of the array.

Write a program to accept 5 elements in the array and display the first and the last elements of the array.

Write a program to accept 5 elements in the array and display the alternate elements of the array.

Write a program to accept 5 elements in the array and count the number of odd elements and even elements present in the array.

Write a program to accept 5 state names in the array and display the same.

Write a program to accept 5 elements in the array and sum all the elements present in the array.

Write a program to accept 5 elements in the array and sum the odd position elements and sum of  even position elements of the array.

Write a program to accept temperature of the week and find the highest temperature of the week.

Write a program to accept five numbers in the array and find the largest and the smallest element in the array.

Write a program to accept five numbers in an array and a search element from the user and find whether the element is present in the array or not by Linear search method. 

Write a program to accept five numbers in an array and a search element from the user and find whether the element is present in the array and if present display the position of the element by Linear search method. If the element is not found in the array display a suitable message.

Write a program to accept five numbers in an array and a search element from the user and find whether the element is present in the array by Binary Search method.

Write a program to accept five numbers in an array and  sort the elements in the ascending order by Bubble Sort Method.

Write a program to accept five numbers in an array and  sort the elements in the ascending order by Selection Sort Method.

Write a program to accept 4 elements in each array and merge them to a single array. B array should be added after A array.

Write a program to accept 4 elements in each array and merge them to a single array alternatively.

Write a program to accept m and n elements in each array and merge them to a single array alternatively.

Accept a array of five elements. Display the array inputted. Remove the first element and rearrange the elements and display the new array. 

Structure


Basic programs in Structure

Write a program to accept roll, name and age in a structure and display the same.

Write a program to accept roll, name and age for two different students in a structure and display the same.

Write a program to accept roll name age of five different students and display the same without using an array.

Write a program to accept the data roll, name, age in one structure variable, copy the details to another structure variable and display the second structure variable.


Structure Array

Write a program to accept roll name age of five different students and display the same using array.

Declaring structure globally

Write a program to accept roll, name, age in a structure pass it to the structfun() and display the details of the student from the function.

Write a program to accept roll, name, age for three different students in a structure pass it to the function and display the details of the students from the function.

Write a program to accept roll, name, age for three different students in a structure pass it to the function using pointer and display the details of the students from the function.

Nested Structure 

Create a structure which will accept the roll, name, age of a student. The name is further subdivided as first name and Surname. Accept a detail of a student and display the same. 

Nested Structure Array

Create a structure which will accept the roll, name, age of three different students. The name is further subdivided as first name and Surname. Accept a detail of a student and display the same.

Union of Structure

Write a program to accept the details of a teacher or a student on user choice, storing different data types in the same memory location.

Strings

Write a program to accept a character and display the same.

Write a program to accept a word and display the same.

Write a program to accept a sentence and display the same.

Write a program to accept a word from the user and display 3 characters from the left of the word.

Write a program to accept the word and display the output in pyramid structure.

Write a program to accept a word and display each character in a separate line along with its position.

Write a program to accept a word and display the ASCII value of the characters present in the word.

Write a program to accept a word, copy the word to another word and display both the word and compare whether they are equal or not.

Write a program to accept two words from the user and check whether they are equal or not.

Write a program to accept a word, copy the word to another word, reverse the word and check whether both are equal or not.

Write a program to accept a word and check whether it is Palindrome or Not.

Write a program to accept a word and check whether it is Palindrome or Not.

Accept a word and count the number of vowels present in the word.

Accept a word and count the number of vowels and consonants present in the word.

Accept a word and count the number of capital letters and small letters present in the word. 

Accept a sentence and count the number of words present in the sentence. 

Accept a sentence and display each word in a separate line.  

Accept a sentence and find the largest word present in the sentence.

Accept a sentence and count the number of articles present in the sentence.

Accept a sentence and a word and count the frequency of the word present in the sentence. 

Accept a sentence and count the number of vowels present in each word of the sentence.

Pointers and Data Structure

Write a program to display the address of a variable whose value is 5.

Write a program to declare a pointer variable and store the address of another variable and display the value and address of the variables.

Write a program to declare a pointer variable, pointer to pointer variable store some values and display the result.

Write a program to accept the value of a and b and store the sum in variable. Also display the address of a,b,c.

Generate natural numbers from 1 to 5 along with the address of the variable.

Accept 5 elements in the array and display the array elements along with the address.

Write a program to accept a name and display each character of the name along with the address. 

Write a program to add two numbers using call by reference.

Write a program to accept the word in main() pass it to the function and display all the character present in the word. 

Write a program to accept a word and find the length of the word using pointers.

Write a program to create arith() which can calculate the sum and difference of two numbers acceped from the user.

Text and Binary Files in C


Text File Handling

Write a program to create a text file in write mode and store the roll,name,age in the file given by the user. The name of the file is myfile.txt.

Write a program to add a record in the existing text file myfile.txt. The structure of the file is roll,name,age.

Write a program to display the first record of the text file myfile.txt. The structure of the file is roll,name,age.

Write a program to display all the records of the file myfile.txt. The structure of the file is roll,name,age.

Write a program to create a text file in write mode and store the roll,name,mark1,mark2 in the file for three records given by the user. The name of the file is myfile.txt.

Write a program to read all the records from the text file myfile.txt and display the roll, name, mark1, mark2 and total of each student. The structure of the file is roll, name, mark1, mark2.

Write a program to accept roll,name,mark1 and mark2 and store it in a text file myfile.txt. The number of records to be entered in the text file is 3. Read all the record from the file and display the roll, name, mark1,mark2 and total. Also display the status of each student. If both the marks are greater than or equal to 40 declare it as Pass else Fail.

Binary File Handling

Write a program to accept roll,name, mark1 and mark2 of a student and store it in a binary file "myfile.txt"

Write a program to accept roll,name, mark1 and mark2 of three different students and store it in a binary file "myfile.txt".

Write a program to read all the records from the binary file myfile.txt and display the roll, name, mark1,mark2 and total of each student. The structure of the file is roll, name, mark1, mark2.

Write a program to accept roll,name, mark1 and mark2 of a student and store it in a binary file "myfile.txt". Read the record from  the file and display the roll, name and total.


Stack and Queues

Stack and Queue using Array

Write a program to implement a Stack using Array. The stack contains 4 options push, pop, display and exit. The size of the stack is 5.

Stack Program using array

1. Push

2. Pop

3. Display

4. Exit

Enter your choice

Write a program to implement a Queue using Array. The stack contains 4 options insert, delete, display and exit. The size of the queue is 5.

Queue Program using array

1. Insert

2. Delete

3. Display

4. Exit

Enter your choice


Linked List

Write a program to implement the Link List with the following option

1. Create a node

2. Add a node at the beginning

3. Add a node at the end

4. Add a node at given position

5. Delete a node at the beginning

6. Delete a node at the end

7. Delete a node at the given position

8. Traversing the link list

9. Search a element in the link list

10. Sort the nodes in ascending order

11. Exit


List of Programs in Python

Select the Menu for the Solved programs Basic Programs  General Programs  Write a program to display the message "Hello World" on ...