I have tried this problem but I'm getting errors.. Is there anyone who can help me in solving this one ??
Create a function that takes an array of numbers and returns "Hello World!" if the digit 5 appears in the array. Otherwise, return "there is no 5 in the array". Array of numbers is 12 65 4 67 0987 234 87 89 6745 567 987 476 708 36 5587 798 884 671 7889 We have to check single digit of array element and compare it with 5 if 5 then hello world else no 5 12 so element is 1 and 2 You will get this 2 elements by mod operator 12%10 so you will get 2 and and divide the number by 12/10 you will get 1 And compare 1 and 2 with 5 you get the desired output a=n%10 n=n/10 If(a==5) Hello world void fun(int arr, int n){ bool flag = 0; for(int i = 0; i < n; i++){ int cnt = 0; while(arr[i] > 0){ arr[i] = arr[i]/10; cnt++; } if(cnt == 5){ flag = 1; } } if(flag){ cout<<"Hello world"; } else{ cout<<"there is no five"; } } Can anyone help me in solving this problem in c or c++??