Solution:: Week 10 May - 14 May-2021
Solution:: Week 10 May - 14 May-2021
Problem Statement:
Write a program in which you have to define a function displayDiagnol which will have two integer arguments
named rows and cols. In the main function, take the values of rows and columns from the users. If the number
of rows is same as numbers of columns then call the displayDiagnol function else show a message on screen
that number of rows and columns is not same.
The function will take the value of rows and cols which are passed as argument and print the output in matrix
form. To print the values in the matrix form, nested loops should be used. For each loop, you have to use a
counter variable as counter. When the value of counters for each loop equals, then it prints the value of row at
that location and prints hard coded zero at any other location.
Example if the user enters rows and cols as 3, then the output should be like this
100
020
003
Solution:
#include <iostream>
using namespace std;
rows = 0;
columns = 0;
cin>> rows;
cin>> columns;
if(rows == columns)
else
return 0;
// function definition
if(i==j)
cout<< "\n";