Create a complete pseudo-code program in C++ to do the following using the Pseud
ID: 3881094 • Letter: C
Question
Create a complete pseudo-code program in C++ to do the following using the PseudoCode language developed in class using Absolute Addressing.
There is 1 deliverable:
1. You should include the input cards shown below as a test.
THE PROGRAM:
First you will read in a value N which holds the number of values to be read in. (so if N is 20 then there will be 20 more cards to read in.)
Read in N values into an array.
Bubble-Sort the array {you must use the bubble-sort algorithm!!!
After sorting the values print out the N values in Ascending order
The next page shows the input cards to use for your test (include in your file) AND then what your output should look like.
Note : you can assume that N will be in the range 5 to 300 if that helps.
INPUT CARDS
10
1
5
3
4
2
9
8
6
7
10
OUTPUT SCREEN
1
2
3
4
5
6
7
8
9
10
Explanation / Answer
#include<iostream>
using namespace std;
int main()
{
int n,i,j,temp;
cout<<"Input Cards "; //taking input for number of cards
cin>>n;
int a[n];
for(i=0;i<n;i++) //accepting the element for the array
cin>>a[i];
for(i=0;i<n;++i) //outer loop
{
for(j=0;j<n-i-1;j++)
if(a[j]>a[j+1]) //checking condition for ascending order
{
temp=a[j]; //swapping the element
a[j]=a[j+1];
a[j+1]=temp;
}
}
cout<<"Output Cards "; //displaying the sorted cards
for(i=0;i<n;i++)
cout<<a[i]<<endl;
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.