Friday 24 November 2017

C++ Program to Implement Sorted Array


Code:

#include   iostream
#include   iomanip
#include   string
using namespace std;

int main()
{
    int array[100001] = {0}, value;
    char ch = 'y';
    while (ch == 'Y' || ch == 'y')
    {
        cout<<"Enter an integer to be inserted: ";
        cin>>value;
        array[value] = value;
        cout<<"Do you want to insert more ( Y or N): ";
        cin>>ch;
    }
    for(int i = 0; i < 100001; i++)
    {
        if (array[i] != 0)
            cout<
    }
    cout<
    return 0;
}


Output:

Enter an integer to be inserted: 10
Do you want to insert more ( Y or N): Y
Enter an integer to be inserted: 6
Do you want to insert more ( Y or N): Y
Enter an integer to be inserted: 11
Do you want to insert more ( Y or N): Y
Enter an integer to be inserted: 3
Do you want to insert more ( Y or N): Y
Enter an integer to be inserted: 8
Do you want to insert more ( Y or N): Y
Enter an integer to be inserted: 2
Do you want to insert more ( Y or N): Y
Enter an integer to be inserted: 7
Do you want to insert more ( Y or N): Y
Enter an integer to be inserted: 1
Do you want to insert more ( Y or N): N
1  2  3  6  7  8  10  11


------------------
(program exited with code: 1)
Press return to continue


More C++ Programs:














100+ Best Home Decoration Ideas For Christmas Day 2019 To Make Home Beautiful

Best gifts for Christmas Day | Greeting cards for Christmas Day | Gift your children a new gift on Christmas day This Christmas d...