We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5
IT22111- PROGRAMMING FOR PROBLEM SOLVING LABORATORY
List of programs for lab sessions
_______________________________________________________________ Exercise 1 Usage of Basic Linux commands Commands: mkdir, cd, mv, rm, ls, cat, vi, cp, rm etc., Exercise 2 C Programming using Simple statements and expressions 1. Print your name, I am an Engineer. Sample: My name is Sivaji, I am an Engineer. Get familiar with vi, cc, and ./a.out. 2. Print your details Name, age, Gender (M/F), Address, CutOff (in HSC) with one detail per line and tab between label and value. 3. Read your details through keyboard and display them. (Use gets() for string). 4. Kumar has Rs.x and Sheela has Rs.y. Both exchange their amounts. Simulate this as an interactive C program. 5. Calculate the daily wage of a labour taking into account the pay per day, number of hours worked, TA, and DA. 6. Box 1 has M apples and Box 2 has N apples. Assuming you do not have any other space/storage to hold the apples, exchange the apples in Box 1 and Box 2. (Swap without temp). 7. Display the sum of ASCII values of vowels in English letters. 8. Read a complex number. Display the number in the format a+ib. and calculate its modulus value as the square root of the sum of squares of a and b. (Use sqrt, pow functions) Exercise 3 Scientific problems solving using decision making 1. Read the age of a person and check of the person is eligible to vote (> 18 years). 2. Write a C program to check if a year is leap or not 3. Ram, Balaji, and Kumar are siblings aged x,y, and z respectively. Find theyoungest and oldest among them. 4. ‘Solar System’ is an application that reads a number between 1 and 9 and prints the respective planet. For example, if it reads 3, it displays ‘Venus’. Develop the application Solar System. (simple switch) 5. Read the marks scored by a student in a subject and calculate the grade using the above grading system. Grade O S A B C D Mark 100 90-99 80-89 70-79 60-69 50-59 range 6. Calculate the ESE marks of a subject as 40% (Internal_mark) + 60%(External_mark) for theory subject and 60%(Internal_mark) + 40%(External_mark) for practical subject. Internal_mark is calculated as 70%(CAT1+CAT2+AT3) + 30%(Assignment1 + Assignment2 + Assignment3). The External_mark is awarded for 100. (Hint: Read ‘P’ and ‘T’ to differentiate practical and theory subjects). 7. “This Month” is an application that reads two numbers. The first number represents the month ranging between 1 and 12 and the second number represents the year. Print the numbers of days in that month. For example, if it reads 3, it displays 31. Develop the application ‘This Month’. Take care of Leap years. (Use if-else/Switch).
Exercise 4 Scientific problem solving using looping
1. An astrologer calculates the day’s fortune as the sum of the numbers in the year of birth. Write a C program to find help him. (hint: find the sum of digits in a number). 2. Write a C program to check if a number is Prime or not. 3. Write a C program to count the number of ways, the letters in a name can bearranged. (Hint: letters can be arranges in n! ways) 4. Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”. 5. Generate the grade sheet with all subjects along with their credits; calculate the GPA (with 2 digits precision) as the fraction of total credits earned over the total credits in Semester 1. 6. Assume SVCE mark entry portal has facility to enter the ESE marks and its equivalent in words by the teacher. However, the teachers wish that itwouldbe great if the marks in number are converted to their words by the software. Can you please develop a C program for the same? Marksrange from 0 -100. Sample: 81 – Eight One 7. Print the following patterns using the concept of nested loops Exercise 5 Simple programming for one dimensional and two-dimensional arrays 1. Read the heights of N kids and find the maximum height. 2. Read the marks of m students in N subjects and print the same as a matrix. 3. Write a C program to perform matrix addition. 4. Prof. Siva awards marks for N questions in the range 0-16. Support him in finding the total. Ensure the following: a. Only numbers are entered b. If he awards marks out of the range, ask him to re-enter the mark c. limit the total to 100. 5. Dr. Sudha marks daily attendance of N students as a sequence of ‘P’ and ‘A’ for present and absent respectively. Help her to find the number of present and absentees for a day. 6. Prof. Vimal is interested in forming project teams as a triplet of every alternate student in his class. Say, if 10,11,12,13,14,15 are the roll numbers of the students, then team_1 will be (10,12,14) and team_2 will be (11,13,15). Automate this team formation to Vimal when he gives the class size and the roll numbers. Ensure that this is possible only when the class size if a multiple of three. 7. Write a program to find the largest 2 numbers and the smallest 2 numbers in the given array 8. Read the marks scored by M students in N subjects and perform thefollowing: a) Calculate the subject-wise maximum marks b) Calculate the total of each student c) Find the row index of the topper student d) Find the grand total of all marks of all students
Exercise 6 Solving problems using Strings
1. Write a C program to print each character in a string in a line 2. Write a C program to count the frequency of vowels in a string. 3. A numerologist suggests renaming a person by repeating the vowel in the name subsequent to its existing position. Ex: Sivakumar :Siivaakuumaar. Write a C program to automate his suggestion. 4. Read the first name, middle name, and last name of a person and form a full name as the concatenation of them. (Using and without using libraryfunctions). 5. Write a C program to design a encryption technology that replaces every non-vowel character of a string with its subsequent character in a rotation. Ex: BASKARZ : CATLASA. 6. The strength of a name is the sum of the ASCII values of its characters. Find the strength of a name. 7. Read a string and check if it’s a palindrome. (Using and without usinglibrary functions). 8. Write a program to convert from upper case to lower case and vice versa of an alphabet and print the old character and new character as shown in example (Ex: a->A, M->m). 9. Write a program to accept gender ("M" or "F") from command line arguments and age as an input (1-120) and print the percentage of interest based on the given conditions. Interest == 8.2%, Gender ==> F, Age ==>1 to 58, Interest == 7.6% Gender ==> F, Age ==>59 -120, Interest == 9.2%, Gender ==> M, Age ==>1-60 Interest == 8.3%, Gender ==> M, Age ==>61-120
Exercise 7 Programs to illustrate user defined functions
1. Write a C program to implement a pocket calculator using user defined functions 2. Write a C program to calculate factorial of a number using recursive function. 3. Write a program to pass two numbers to the function print_even(n1,n2) and print all the even numbers between n1 and n2. 4. Write a program to pass two numbers to the function print_prime(n1,n2) and print all the prime numbers between n1 and n2. 5. Create a structure Complex and perform addition, subtraction, and multiplication of 2 complex numbers.
Exercise 8 Programs to illustrate Structures
1. Declare a book with <title, float price, int number_of_pages>. Read the details of a book and print the same. 2. Read 2 book details and print the details of the costlier book. 3. Create a structure STUDENT with <Roll_no,Name,Gender,marks[5], grades[5],GPA>. Calculate the grade of each subject (assuming one-to one mapping of marks and grades) and GPA as the average of marks scored by a student. 4. Calculate the grades and GPA of N students of a class using the STUDENT structure. Exercise 9 Programs to illustrate Pointers 1. Demonstrate address of (*) and indirection (*) operators. 2. Write a C program, to swap two number using pointers 3. Implement a Pocket calculator with arithmetic operators (include increment/decrement also).
Exercise 10File Handling in C
1. Write a C program to read contents in a file and print in console 2. Write a C program to read contents from user through console and write in a file. 3. Read <roll, Name,GPA> of a student from console and write into a file student.txt . 4. Add a new record read from console say <100, Srinivasan,9.8> to student.txt (append). 5. Retrieve the details of a student named “Krishna” and print in console. 6. Copy the contents of student.txt to new_student.txt.
Assignment Questions: Anagrams Isograms Pangrams To reverse a number using recursion To find the length of the string using recursion