Posts

Image
Dynamic Memory Allocations in 2D Array with Linear Search  Input:   Array Row[] Column[]  Output : Position Of A Value    Code:     #include<iostream> using namespace std; int main() {     int i,j,n,row , col,s,t=0;     int **matrix;     cout<<"Enter The Number Of Row : ";     cin>>row;     cout<<"Enter The Number Of Coloum : ";     cin>>col;     matrix= new int *[row];     for(i=0;i<row;i++)     {         matrix[i]= new int [col];     }     cout<<endl<<"Enter The Number of Elements :";     for(i=0;i<row;i++)     {         for(j=0;j<col;j++)         {             cout<<endl<<"Row["<<i+1<<"]"<<"Col["<<j+1<<"]=";             cin>>matrix[i][j];         }     }     cout<<"Enter The Number To Search : ";     cin>>s;     for(i=0;i<row;i++)     {         for(j=0;j<col;j++)        
 Dynamic Memory Allocations in Array With  Linea r Search   #include <iostream> using namespace std; int main() {     int i,n,s,t=0;     int *p;     cout<<"Enter The Number Of  The Elements :";     cin>>n;     p=new int[n];     cout<<"Enter The Elements :"<<endl;     for(i=0;i<n;i++)     {         cin>>p[i];     }     cout<<"Enter An Integer To Search ";     cin>>s;     for(i=0;i<n;i++)     {         if(s==p[i])         {             cout<<"\n\n\t\tElements Found At The Position ="<<"["<<i<<"]"<<endl;             t=1;             break;         }     }     if(t==0)     {         cout<<"\n\n\t\t Elements Not Found ";     }     return 0; }