Lab Assignments CP
Lab Assignments CP
Assignment Questions
1. WAP to input the radius value of any circle through the keyboard and then find out its area.
2. WAP to find out the area of any rectangle. The length and breadth of the rectangle must be
inputted by the user.
3. WAP to find out the sum of first n natural numbers where n is inputted from the keyboard.
4. WAP to input the three sides of any triangle and then find out its area.
5. WAP to swap the values of two variables using a third variable.
6. WAP to swap the values of two variables without using a third variable.
7. WAP to find the sum of the individual digits of any inputted three-digit positive number.
8. WAP to enter the principal, time, and rate of interest. Calculate the simple interest.
9. WAP to convert Fahrenheit to Celsius.
10. WAP to convert Celsius to Fahrenheit.
11. WAP to find the average marks of any student by entering 5 subject marks.
12. WAP to calculate the gross salary of an employee by inputting the basic salary. DA is 45% and
HRA is 30% of the basic salary.
13. WAP to calculate hours, minutes, and seconds by inputting seconds as input. For example:
INPUT: Enter the time value in seconds: 3672
OUTPUT: 1 Hour 1 minute 12 seconds
14. WAP to calculate the KM and Meter value by inputting the distance value as meters. For
example: INPUT: Enter the distance value in meters: 2550
OUTPUT: 2 KMs 550 Meters
15. WAP to find out the largest between three numbers using Conditional operator.
Assignment Questions
Assignment Questions
Assignment Questions
Assignment Questions
Assignment Questions
Assignment Questions
Assignment Questions
1. WAP to find out the sum of the elements of an array using function.
2. WAP to find the largest element of an array using function.
3. WAP to implement Linear search using function.
4. WAP to implement bubble sort using function.
5. WAP to add two matrices using function.
6. WAP to add multiply matrices using function.
Topic: String
Assignment Questions
1. WAP to enter any string and then count how many characters are present in it.
2. WAP to convert the characters of any string to upper case without using any string library
function.
3. WAP to extract the first n characters of any string.
4. WAP to extract the last n characters of any string.
5. WAP to extract a substring from an inputted string. The position from which to start the
substring and the length of the substring will be inputted by the user.
6. WAP to find out the length of any string using a user-defined function XSTRLEN ().
7. WAP to copy the content of one string to another using a user-defined function XSTRCPY ().
8. WAP to concatenate one string at the end of another string using a user-defined function
XSTRCAT ().
9. WAP to compare to strings using a user-defined function XSTRCMP ().
Topic: Structure
Assignment Questions
1. WAP to define a structure BOOK having members as title, author name, no. of pages, and
price. Enter the details of a book and display them.
2. WAP to define a structure POINT having elements as Xco, and Yco. Enter two points and then
find out the distance between them.
3. WAP to define a structure EMPLOYEE having elements as name, empid, department, age, and
salary. Enter the details of 5 employees and display the details of each employee.
4. WAP to define a structure STUDENT having members as name, roll_ no, branch, and CGPA.
Enter the details of 5 students. Display the details of the student having the highest CGPA.
5. WAP to define a structure EMPLOYEE having elements as name, empid, department, age, and
salary. Enter the details of 5 employees. Display the details of those employees whose salary
is greater than the average salary value of all employees.
6. WAP to define a structure COMPLEX having members as real, and imag. Define a user-defined
function ADDCOMPLEX () which will receive two structure variables as its arguments and will
return a structure variable. The ADDCOMPLEX () will add two complex numbers.
7. WAP to define a structure DISTANCE having members as kms, and metres. Define a user-
defined function ADDDISTANCE () which will receive two structure variables as its arguments
and will return a structure variable. The ADDDISTANCE () will add two distance values.
8. WAP to define a structure TIME having members as hour, minute, and second. Define a user-
defined function ADDTIME () which will receive two structure variables as its arguments and
will return a structure variable. The ADDTIME () will add two different time values.
Assignment Questions
1. WAP to allocate memory dynamically for an integer array of size 10. Enter the array elements
and display their sum.
2. WAP to allocate memory dynamically for an array. Find out the largest and smallest element
of the array.
3. WAP to allocate memory dynamically for an integer array. Check whether an inputted
element is present in this array or not.
4. WAP to allocate memory dynamically for a character array. Store your first name in the
allocated memory. Now reallocate the memory using realloc () to store your entire name and
then display it.
Assignment Questions
1. WAP to count the number of characters, words, blank spaces, and tabs from a text file.
2. WAP to copy the content of one file to another file.
3. WAP to convert the characters of a file from lower case to upper case and vice versa.
4. Write a program to read and display the content of a file using command line argument.
5. WAP to copy the content of one file to another file. Both source file name and target file name
must be passed from the command prompt.
6. WAP to find out the sum of 5 integers passed from the command prompt.
7. WAP to pass your full name from the command prompt and then display it.