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.
Login
Login
OnlineGDB Q&A
Questions
Unanswered
Tags
Ask a Question
Ask a Question
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.
please-help
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
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;
}
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
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.
...