Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion exercises/verify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,34 @@ The number 3 is [not] present in the array.
*/

#include <iostream>

using namespace std;

bool checkNum(int* N, int num){

for(int i=0;i<sizeof(N);i++){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Questo sizeof non va bene così, andrebbe fuori dall'index generandoti errore


if(num==N[i]){
return true;
}
}
return false;
}

int main()
{
// placeholder
int number;
int N[10] = {3, 4, 5, 1, 2, 3, 4, 9, 13, 0};

cout<<"Insert number: ";
cin>>number;

if(checkNum(N,number)){
cout<<"The number "<<number<<" is present in the array."<<endl;
}
else{
cout<<"The number "<<number<<" is not present in the array."<<endl;
}

return 0;
}
Loading