Question

Write a C++ program in this new file. (1 point) Accept 10 integers from the user...

Write a C++ program in this new file.

  1. (1 point) Accept 10 integers from the user using an array and a loop.
  2. (2 points) Print the numbers in reverse order from the order in which they were entered.
  3. (4 points) Sort the array from lowest to highest number and print the numbers in this new, sorted order.
0 0
Add a comment Improve this question Transcribed image text
Answer #1
  1. (1 point) Accept 10 integers from the user using an array and a loop.

#include<iostream.h>

#include<conio.h>

void main()

{

            clrscr();

            int arr[10], i;

            cout<<"Enter array elements : ";

            for(i=0; i<10; i++)

            {

                        cin>>arr[i];

            }

            getch();

}

  1. (2 points) Print the numbers in reverse order from the order in which they were entered.

#include<iostream.h>

#include<conio.h>

void main()

{

            clrscr();

            int arr[50], size, i;

            cout<<"Enter array size : ";

            cin>>size;

            cout<<"Enter array elements : ";

            for(i=0; i<size; i++)

            {

                        cin>>arr[i];

            }

            cout<<"Now the Reverse of the Array is : \n";

            for(i=size-1; i>=0; i--)

            {

                        cout<<arr[i]<<" ";

            }

            getch();

}

3. (4 points) Sort the array from lowest to highest number and print the numbers in this new, sorted order.

#include <iostream.h>

#include<conio.h>             

void main()                       

{

            int a[100],n,i,j,tmp;

            cout<<"Array size: ";

            cin>>n;

            cout<<"Elements: ";

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

    {

            cin>>a[i];

    }

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

            {

                        for (j = 0; j < n; j++)            

                        {

                                    if (a[j] > a[i])                                          {

                                                int tmp = a[i];        

                                                a[i] = a[j];           

                                                a[j] = tmp;            

                                    }

                        }

            }

            cout<<"\n\nAscending : ";                    

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

          {

            cout<<"\n";

                        cout<<a[i];

            }

            getch();

}

Add a comment
Know the answer?
Add Answer to:
Write a C++ program in this new file. (1 point) Accept 10 integers from the user...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT