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
Why is c++ still popular?
what is multi-threading in C++?
Explain terminate() and unexpected() function?
What are the important differences between c++ and java?
What is meant by forward referencing and when should it be used?
What are c++ data types?
Why do we need constructors in c++?
You run a shell on unix system. How would you tell which shell are you running?
What is abstraction in c++ with example?
can any one help to find a specific string between html tags
which is changed to a sting..
weather.html looks (for location) is
What is a node class in c++? Explain the benefits of proper inheritance. Who was the creator of c++? I want explanation for this assignment: how to connect mysql
database using c/c++,please explain this detailly? Is oops and c++ same?