You have to take 2 arrays of length 10. Input the values of
array 1 from the user. Then copy the values of array 1 to
array 2 in ascending order

For example if user enters 9, 5, 6, 8, 1, 0, 2, 7, 4, 3
then copy the smallest element i.e. 0 first followed by 1,
2 and so

Answer Posted / prasenjit roy

#include "stdio.h"
#include "conio.h"

int main(int argc, char* argv[])
{
int arr[]={9, 5, 6, 8, 1, 0, 2, 7, 4, 3},i,j,iTmp;
printf("original :: ");
for ( i = 0; i < sizeof(arr)/sizeof(int) ; i++)
printf("%d, ",arr[i]);
printf("\b\b \n");

for ( j = 0; j < sizeof(arr)/sizeof(int) -2; j++ )
{
for ( i = sizeof(arr)/sizeof(int) -1; i >
j ; i-- )
{
if ( arr[i] < arr[j] )
{
iTmp = arr[j];
arr[j] = arr[i];
arr[i] = iTmp;
}
}
}

printf("modified :: ");
for ( i = 0; i < sizeof(arr)/sizeof(int) ; i++)
printf("%d, ",arr[i]);
printf("\b\b \n");

while( ! _kbhit() );
return 0;
}

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why is c++ still popular?

589


what is multi-threading in C++?

617


Explain terminate() and unexpected() function?

628


What are the important differences between c++ and java?

606


What is meant by forward referencing and when should it be used?

560






What are c++ data types?

643


Why do we need constructors in c++?

619


You run a shell on unix system. How would you tell which shell are you running?

663


What is abstraction in c++ with example?

564


can any one help to find a specific string between html tags which is changed to a sting.. weather.html looks (for location) is somewhere #include #include #include using namespace std; string find_field(string myPage,string); int main (void) { string page, line, location, temperature; ifstream inputFile("weather.xml"); while(getline(inputFile, line)) { page.append(line); line.erase(); } // Now page is a string that contains the whole xml page // Here you need to write something that finds and // extracts location and temperature from the XML // data in the string page and stores them in // the strings location and temperature respectively location=find_field(page,"location"); temperature=find_field(page,"temp_c"); cout << "Location: "<

1643


What is a node class in c++?

646


Explain the benefits of proper inheritance.

640


Who was the creator of c++?

563


I want explanation for this assignment: how to connect mysql database using c/c++,please explain this detailly?

1587


Is oops and c++ same?

580