Write a c program to search page 11 in a book where you don’t visit every page from 1 to 50. You open any random page in the book and check its page number. If the current page number is greater than 11, then 11 is on the left side of the current page.
#include <iostream>
using namespace std;
int main()
{
int n=50;
int pages[n];
for(int i=0;i<n;i++){
pages[i]=i+1;
}
int random_page;
cout<<"\nEnter the random page: ";
cin>>random_page;
int search_page=11;
if (random_page>search_page)
cout<<"Page 11 is on the left side of the current page";
else if(random_page<search_page)
cout<<"Page 11 is on the right side of the current page";
else
cout<<"The current page is page 11";
return 0;
}
Comments
Leave a comment