dimanche 28 juin 2020

Program to check any number exist in 2D array

I know how to check if number exist in the array, but not in a 2D array.

Please help me in 2D.

#include<iostream>
using namespace std;

int main()
{
   int a[3] = { 4,5,6 };
   int b, c;
   int x = 1, fact = 1;

   cout << "enter no ";
   cin >> b;

   for (int i = 0; i < 3; i++) 
   {
      if (b == a[i]) {
         c = a[i];
         break;
      }
   }
   cout << "no entered is present" << endl;
}

Aucun commentaire:

Enregistrer un commentaire