School of Information Technology and Engineering ITA419 – Programming in C and Algorithm Design Lab

Lab Exercises CYCLE SHEET – II

ARRAYS
1. Read values into an one dimensional array and compute the sum of their squares. 2. Enter elements into an array and reverse the order of the elements in the array. 3. Read elements into an array. Write a Program to find duplicate elements in the array and display the resultant array by removing the duplicates. 4. Read a line of text into a character array and perform the followingoperation: a. Count the number of Upper case , Lower case, digits andspecial characters. b. Convert Upper case to Lower case and vice versa without using string library functions. c. Count the number of words, lines and characters in a given text. 5. Write a program to copy m consecutive characters from String S1 beginning at position n into another string S2. 6. Read Two Matrix A and B. Compute the Matrix Addition and display the resultant matrix. 7. Read Two Matrix A and B. Compute the Matrix Multiplication and display the resultant matrix. 8. Read a Matrix A of size m * n and compute its transpose and display the result. 9. Write a program to read in an array of names and sort them in alphabetical order and display the result. 10. The Examination results of n students are tabulated as follows: Register No Subject 1 | | | Subject 2 | | | Subject 3 | | |

11. Write a program to read the data and determine the following: a. Total Marks obtained by each student. b. Highest Marks in each Subject. c. Register No of Students who secured highest in each subject. d. Student who obtained the highest total marks.

12. A certain grade of steel is graded according to the following conditions: a. Hardness must be greater than 50 b.Carbon content must be less than 0.7 c. Tensile strength must be greater than 5600
The grades are as follows: Grade is 10 if all three conditions are met Grade is 9 if conditions (i) and (ii) are met Grade is 8 if conditions (ii) and (iii) are met Grade is 7 if conditions (i) and (iii) are met

Perform swapping of two numbers using call by reference method. carbon content and tensile strength of the steel under consideration and output the grade of the steel. he should get at least 45 percent in A. In all other cases he is declared to have failed. b. finds the product of these two and returns the product which is printed through main( ). Call this function from main( ) and print the results in main( ). A library charges a fine for every book returned late. . c. However. for 6-10 days fine is one rupee and above 10 days fine is 5 rupees. average and standard deviation of these numbers. 17. break and continue) Pointers 16. failed or is allowed to reappear in B. Write a program to receive marks in A and B and Output whether the student has passed. A university has the following rules for a student to qualify for a degree with A as the main subject and B as the subsidiary subject: a. If he gets less than 45 percent in B and 65 percent or more in A he is allowed to reappear in an examination in B to qualify. 20. 13. Read two strings and perform string concatenation using pointers. Write a function which receives a float and an int from main( ). 14. Write a program to accept the number of days the member is late to return the book and display the fine or the appropriate message. 18. If he gets than 55 percent in A he should get 55 percent or more in B.Grade is 6 if only one condition is met Grade is 5 if none of the conditions are met Write a program. Write a program to print all prime numbers from 1 to 300. If you return the book after 30 days your membership will be cancelled. 19. (Hint: Use nested loops. 15. Write a function that receives 5 integers and returns the sum. which will require the user to give values of hardness. He should get 55 percent or more in A and 45 percent or more in B. d. For first 5 days the fine is 50 paise. Write a C Program to perform arithmetic operation and display the results along with its address.

27. month and year to represent the date of birth. Call this function from main( ) and print the results in main( ). Print the formatted structure data. Prepare the Bill and print it. and c. Write a function to print the data of a student whose roll number is given. . Write a function that receives marks received by a student in 3 subjects and returns the average and percentage of these marks. Then ask the user to enter current date. Department. 28. 29. d. date of joining. Develop a program to read data for 10 students in a class and list them rank-wise. 22. Display the names of those employees whose tenure is 3 or more than 3 years according to the given current date. Design a structure student_record to contain name. Year of joining Assume that there are not more than 450 students in the collage. Define a structure data type date containing three integer members namely day.80 for each unit. There is a structure called employee that holds information like employee code. Declare the structure with the following members: Name char 20 Age int Gender char 1 Marks float b. Course. 250 plus Re 0. a. Write a program to create an array of the structure and enter some data into it. Initialize the members with your values. date of birth and total marks obtained. S = ( a + b + c ) / 2 Structures 23. b. 24. Name.21. 25. If the lengths of the sides of a triangle are denoted by a. then area of triangle is given by Area = S ( S  a )( S  b)(S  c) where. Code to accept 10 telephone customers’ data into a structure object. Code a program to do the following with a structure: a. c. Write a function to print names of all students who joined in a particular year. Create a structure to specify data on students given below: Roll number. The fields are: Customer name Telephone number Units to be billed Calculate Bill Amount. 26. b. which is Rent of Rs. Print the memory space occupied by the structure object. name.

. Write a menu driven program that depicts the working of a library. Create an array of structure to hold records of 20 such cricketer and then write a program to read these records and arrange them in ascending order by average runs. and flag indicating whether book is issued or not. The menu options should be: a. List the books in the order of accession number g. 31.30. List the title of specified book e. price of the book. author name. title of the book. number of test matches that he has played and the average runs that he has scored in each test match. his age. List all books of given author d. Exit Create a structure called library to hold accession number. Add book information b. A record contains name of cricketer. Display book information c. List the count of books in the library f.