4.1

Write a function to read a matrix of size m*n from the keyboard.

## OUTPUT

Enter size of matrix : 3   4

Enter 3 by 4 matrix elements one by one

1    2    3    4

2    3    4    5

3    4    5    6

The given matrix is :

1    2    3    4

2    3    4    5

3    4    5    6

4.2

Write a program to read a matrix of size m*n from the keyboard and display the same on the screen using function.

## OUTPUT

Enter size of matrix : 4   4

Enter 4 by 4 matrix elements one by one

1    2    3    4    7

2    3    4    5    8

3    4    5    6    9

The given matrix is :

1    2    3    4    7

2    3    4    5    8

3    4    5    6    9

4.3

Rewrite the program of Exercise 4.2 to make the row parameter of the matrix as a default argument.

## OUTPUT

Enter column of matrix  :  3

Enter 3 by 3 matrix elements one by one

1    2    3

2    3    4

3    4    5

The given matrix is :

1    2    3

2    3    4

3    4    5

4.4

The effect of a default argument can be alternatively achieved by overloading. Discuss with examples.

## OUTPUT

Enter column of matrix  :  2

Enter 2 by 3 matrix elements one by one

1    0    1

0    2    1

The given matrix is :

1    0    1

0    2    1

4.5

Write a macro that obtains the largest of the three numbers.

## OUTPUT

Enter three values : 4  5  8

large = 8

4.6

Redo Exercise 4.16 using inline function. Test the function using a main function.

Missing

4.7

Write a function power() to raise a number m to power n. The function takes a double value for m and int value for n and returns the result correctly. Use a default value of 2 for n to make the function to calculate the squares when this argument is omitted. Write a main that gets the values of m and n from the user to test the function.

## OUTPUT

Enter the value of m & n

12    6

m to power n : 2985984

m to power n: 144

4.8

Write a function that performs the same operation as that of Exercise 4.18 but takes an int value for m. Both the functions should have the same name. Write a main that calls both the functions. Use the concept of function overloading.