Assignment No 021

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

ASSIGNMENT NO 02

Submitted to: Dr. Rabia Zafar


Submitted by: Waleed Bin tahir
Roll no: 2022-CS-546
Course Tittle: Programming
Section: BS-I-B

Department of information technology


University of engineering and technology Narowal

TASK O1:
Given a matrix, identify if the matrix is symmetric or
not. In the first line, you are given one integer n,
where n is the size of the input square matrix (n ×
n). You have to take all elements in matrix as input
from user. You have to output Symmetric if the
matrix is symmetric and Not Symmetric otherwise.
Note: You have to Use a function Symmetricfinder
for identification.

#include<iostream>
using namespace std;
int array1[3][3],i,j,counter;
void symmetrictf()
{
int i,j;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(array1[i][j]==array1[j][i]){
counter++;
}
}

}
if(counter==9)
{
cout<<"Matrix is syammrtric"<<endl;
for(int i=0;i<=2;i++)
{
for(int j=0;j<=2;j++)
{
cout<<array1[i][j];
cout<<"";
}
cout<<"/n";

OUTPUT:
1
2
3
4
5
6
7
8
9
SYMETTRIC MATRIX:
123
456
789
………………………………….
Task no 02;

Write a function to generate the nth term in a


Fibonacci sequence. Use this function to print first N
terms of the sequence.

SOLUTION:
Program no 1:
#include<iostream>
using namespace std;
int fii(int);
int main()
{
int s;
cout<<"Enter nth value to find the Fibonacci
sequence.";
cin>>s;
fii(s);
}
int fii(int s)
{
int res=0,t=1,u=1;
cout<<t<<endl;
cout<<u;
for(int i=1;i<=a;i++)
{
result=t+u;
t=u;
t=res;
cout<<endl<<result;
}
OUTPUT:
Enter nth value to find the Fibonacci sequence.1
1
1
2
--------------------------------
Process exited after 3.081 seconds with return
value 0
Press any key to continue . . .

You might also like