Logo 
Search:

C++ Programming Forum

Ask Question   UnAnswered
Home » Forum » C++ Programming       RSS Feeds

array, bubble sort

  Asked By: Love    Date: Sep 28    Category: C++ Programming    Views: 1288
  

Exercise 1
1-Write a program that read the linear array A of 10 integer elements and generate another array B such that each element of B equals the square of the corresponding element in the matrix A
2-Write a program that read the linear array A of 25 integer elements and print the numbers that are greater than 10.
Apply the bubble sort algorithm to sort the following array
A[6]={12, 4, 6, 17, 10, 2}
3-Write a C++ code to implement a bubble sort algorithm.
4-Write a C++ code which read an array 0f 30 integer number then use a linear search algorithm to find the location of an element that entered by the user .

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Abhishek Singh     Answered On: May 14

simple use for loop and scanf function.

 
Answer #2    Answered By: Joel Gaitan     Answered On: Nov 28

//simple progarmm that can help you easily
#include <iostream.h>
#include <conio>
void main()
{
char choise;
int array[10];
do{
int n;
cout<< " how many number do you have "<<endl;
cin>>n;
cout<<"enter the number you have"<<endl;
for (int i=0;i<n;i++){
cin>>array[i];
}
int i,j;
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{
if(array[i]>array[j])
{
int temp=array[i]; //swap
array[i]=array[j];
array[j]=temp;
}

}

}
cout<<"arrangnment of number in descending order as follows"<<endl;
for(int i=0;i<n;i++){
cout<<array[i]<<endl;
}
cout<<"enter the choise y to continue or n to stop"<<endl;
cin>>choise;

}
while(choise=='y');
getch();
}

 
Didn't find what you were looking for? Find more on array, bubble sort Or get search suggestion and latest updates.




Tagged: