

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Two exercises from a c programming lab. The first exercise involves declaring a structure variable named 'rectangle' with two member variables 'length' and 'breadth' of type float. The document instructs creating two variables of this structure in the main function, taking user input for both variables, and defining a function 'addrectangle' to add the lengths and breadths of the two rectangles. The second exercise involves calculating the sum of natural numbers using recursion. The user is prompted to enter a number, and the function adds all numbers from 1 to the user-input number.
Typology: Assignments
1 / 2
This page cannot be seen from the preview
Don't miss anything!


9.1 Declare a structure variable rectangle. Define its two-member variable length and breadth of type float. Create two variables of this structure in main () function. Take date form user for both these variable. Define a function addrectangle (). Pass these two structure variable to this function and add the length and breadth of both rectangles. Display the resultant rectangle sides.
9.2 Calculate the sum of natural number using recursion. [Hint: if user enter 5, the function will add all the number from 1 to 5 i.e.; 5+4+3+2+1=15]