PF_Assignment # 03
PF_Assignment # 03
PF_Assignment # 03
Lahore Campus
Page 1 of 8
Trace the output of the following piece of code:
Page 2 of 8
4
Page 3 of 8
7
Page 4 of 8
9
10
11
Page 5 of 8
12
13
14
Page 6 of 8
15
16
17. Write a program that inputs the number of rows and columns from the user. It
then inputs the elements to store in the matrix. The program calculates the sum of
each row and each column and displays on the screen. If it is a square matrix, it
also calculates the sum of diagonal elements and displays it on screen.
18. Write a program that prompts the user to enter a number and reverse it. Write a
function Reverse() to reverse the number. For example, if the user enters 2765,
the function should reverse it so that it becomes 5672. The function should accept
the number as an input parameter and return the reverse number.
Page 7 of 8
19. Write a program that declares a function accepting two parameters. The first
parameter is a floating pointer number and the second parameter is an integer.
The program should multiply the floating-point number by itself the number of
times indicated by the integer. The function should return the result to the main
function. The main function should ask the user for the floating-point number and
integer. It should then call the function and store the result in a variable. Finally,
the main function should display the returned.
20. Write a program that inputs five integers in a one-dimensional array and passes
the array to a function. The function finds the minimum value in the array and
return to main function where it is displayed.
21. Write a function Change() that accepts an array of integers and its size as
parameters. It all array elements by 5 that are divisible by 5 and multiplies other
array elements by 2.
22. Write a program that inputs values in a 2-D array of 5 columns and 5 rows. It
displays these values using a function It passes the array to a function times2()
that doubles the values stored in all elements of array. The program then again
displays the changed values of the array using display() function.
Page 8 of 8