Vous êtes sur la page 1sur 4

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

Lab Exercises CYCLE SHEET II

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

Grade is 6 if only one condition is met Grade is 5 if none of the conditions are met Write a program, which will require the user to give values of hardness, carbon content and tensile strength of the steel under consideration and output the grade of the steel. 13. A library charges a fine for every book returned late. For first 5 days the fine is 50 paise, for 6-10 days fine is one rupee and above 10 days fine is 5 rupees. If you return the book after 30 days your membership will be cancelled. 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.

14. 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. He should get 55 percent or more in A and 45 percent or more in B. b. If he gets than 55 percent in A he should get 55 percent or more in B. However, he should get at least 45 percent in A. c. 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. d. In all other cases he is declared to have failed. Write a program to receive marks in A and B and Output whether the student has passed, failed or is allowed to reappear in B.

15. Write a program to print all prime numbers from 1 to 300. (Hint: Use nested loops, break and continue)

16. Write a C Program to perform arithmetic operation and display the results along with its address. 17. Read two strings and perform string concatenation using pointers. 18. Perform swapping of two numbers using call by reference method.

19. Write a function which receives a float and an int from main( ), finds the product of these two and returns the product which is printed through main( ). 20. Write a function that receives 5 integers and returns the sum, average and standard deviation of these numbers. Call this function from main( ) and print the results in main( ).

21. Write a function that receives marks received by a student in 3 subjects and returns the average and percentage of these marks. Call this function from main( ) and print the results in main( ).

22. If the lengths of the sides of a triangle are denoted by a, b, and c, then area of triangle is given by Area = S ( S a )( S b)(S c)
where, S = ( a + b + c ) / 2

23. Code a program to do the following with a structure: a. Declare the structure with the following members: Name char 20 Age int Gender char 1 Marks float b. Initialize the members with your values. c. Print the memory space occupied by the structure object. d. Print the formatted structure data. 24. Code to accept 10 telephone customers data into a structure object. The fields are: Customer name Telephone number Units to be billed Calculate Bill Amount, which is Rent of Rs. 250 plus Re 0.80 for each unit. Prepare the Bill and print it. 25. Design a structure student_record to contain name, date of birth and total marks obtained. 26. Define a structure data type date containing three integer members namely day, month and year to represent the date of birth. 27. Develop a program to read data for 10 students in a class and list them rank-wise. 28. Create a structure to specify data on students given below: Roll number, Name,

Department, Course, Year of joining Assume that there are not more than 450 students in the collage. a. Write a function to print names of all students who joined in a particular year. b. Write a function to print the data of a student whose roll number is given.

29. There is a structure called employee that holds information like employee code, name, date of joining. Write a program to create an array of the structure and enter some data into it. Then ask the user to enter current date. Display the names of those employees whose tenure is 3 or more than 3 years according to the given current date.

30. A record contains name of cricketer, his age, number of test matches that he has played and the average runs that he has scored in each test match. 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.
31. Write a menu driven program that depicts the working of a library. The menu options should be: a. Add book information b. Display book information c. List all books of given author d. List the title of specified book e. List the count of books in the library f. List the books in the order of accession number g. Exit Create a structure called library to hold accession number, title of the book, author name, price of the book, and flag indicating whether book is issued or not.