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



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

Answer / 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

More C++ General Interview Questions

What is the difference between stack and heap memory?

1 Answers  


How can I learn dev c++ programming?

1 Answers  


Explain the operation of overloading of an assignment operator.

1 Answers  


How is an Abstract Base Class(ABC) related to an "Abstract Data Type" (ADT)

2 Answers  


How long does this loop run: for(int x=0; x=3; x++) a) Never b) Three times c) Forever

17 Answers   Datavance, Quark, VEL, Wipro,


Explain the use of this pointer?

1 Answers  


If you hear the cpu fan is running and the monitor power is still on, but you did not see anything show up in the monitor screen. What would you do to find out what is going wrong?

1 Answers  


What is a stack? How it can be implemented?

1 Answers  


Snake Game: This is normal snake game which you can find in most of the mobiles. You can develop it in Java, C/C++, C# or what ever language you know.

1 Answers  


Difference between Operator overloading and Functional overloading?

10 Answers   HP,


Is map sorted c++?

1 Answers  


What are the c++ access specifiers?

2 Answers  


Categories