
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
This lab work is assigned by Nauman Shamim at Pakistan Institute of Engineering and Applied Sciences, Islamabad (PIEAS) for Computer Fundementals course. It covers following topics: Lab, Function, Arguments, Square, Area, Rectangle, Driver, Program, Integer, Develop
Typology: Exercises
1 / 1
This page cannot be seen from the preview
Don't miss anything!

Computing Fundamentals
Write the following functions
Area of a Rectangle (Function) The function should accept two arguments i.e. length and width of the rectangle and should return the area of the rectangle, the definition of the function is as under int areaRect(int, int); Use the function Use the function areaRect() and develop a program that allow user to enter the length and width of the rectangle, the program will display the area of the rectangle calculated by the function areaRect
Square or Not (Function) Develop a function that accepts two integer values as length and width of a shape and returns 0 or 1. A 1 will be returned if the shape is a square otherwise a 0 will be returned, the definition of the function is given below int isSquare(int l, int )
Use the function Write a program that will ask use to enter length and width of a shape and will inform the user weather the shape is a rectangle or a square.
Extension Develop a program that will use the functions areaRect() and isSquare(), the program will ask user to enter two integer values as length and width of a shape, the program will display type of shape i.e. square or rectangle and will display the area of the shape as well.
How Many Squares (Function) Ahmed has large number of wooden boards, he wants to cut them into squares of different sizes to be used in decoration of his house, develop a function that will accept the length and width of the board along with one side of the square, the function will return the number of smaller square boards that can be made from the larger board.The definition of the function is given below int howManySuquares(int, int, int)
Driver Program Develop a driver program to test the working of the function developed for Ahmed Extension (Function) It is possible that the size of the board may be smaller then the size of the square that have to be made from that board, for such cases the howManySquares() function may not perform well, extend the function and display an error message, the function will return a negative value for such cases, a negative value is a way to indicate that the function cannot perform the desired operations
Extension (Program) Extend the howManySquares() driver program and extend it to demonstrate that the function performs well for wrong inputs
Extension (Function) Ahmed want to cut the board in smaller boards which may or may not be squares, extend the howManySquares() function and write a new function howManyRectangles(), the function will accept four parameters as length,width of board (larger), and length, width of required board piece(smaller), the function will return the number of smaller boards of desired dimension that can be made from the larger board given. The definition of the function is given below
int howManyRectangles(int,int,int,int)
Driver Program Write a driver program to demonstrate the working of howManyRectangles() function,
Extension (Function) Extend the howManyRectangles() function to cope the problems such as the board provided to make smaller boards is smaller then desired smaller boards
Driver Program Write a driver program to demonstrate the working of the extended howManyRectangles() function
Docsity.com