Answer to Question #236036 in C++ for shivam

Question #236036

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.

1
Expert's answer
2021-09-11T23:39:55-0400


#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS