c++ - How does one pull a specific number from an array of randomly generated numbers using an if...else statement? -


bool statsarray::isnumberfound(int somenumber) {      if (data[size] == somenumber)         {             cout << "congrats, have perfect score!" << endl;         }          else          {             cout << "sorry, not have perfect score." << endl;         }     return 0;  } 

not sure if i'm on right track, pull score of 100 using:

examdata.isnumberfound(100); 

from array of randomly generated numbers.

what reasons using if-else statement here? iterate on elements using for-loop instead.

for(int = 0; < numofelements; i++) {     if(data[i] == somenumber) {         cout << "congrats, perfect score!" << endl;         return true;     } } // nothing matched.. cout << "sorry, not have perfect score." << endl; return false; 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -