Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

how can i solve this question in c++ language

0 votes
asked Oct 31, 2018 by sarah
Write a function that receives an array, and check if it has the numbers 123 consequently or not. Such as an array {3,4,5,1,2,6} returns false, while array {4,5,1,2,3} returns true. Test function with an integer array from your own data.

1 Answer

0 votes
answered Nov 3, 2018 by RoadRomeo1 (260 points)
#include<iostream.h>
#include<conio.h>

using namspace std;

boolean test(int arr[]){
int count=0;

for(int i=0;i<n;i++){

else if(arr[i]==count){
count++;

if(count==3){
return true;
}

}

}

if(count<3){
return false;
}
}

void main(){
clrscr();
count<<"Enter the value of n";
cin>>n;
int arr[n];
for(int i=0;i<n;i++){
cin>>a[i];
}

boolean anwer=test(arr);
cout<<answer;
}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...