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 / 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 |
class basex { int x; public: void setx(int y) {x=y;} }; class derived : basex {}; What is the access level for the member function "setx" in the class "derived" above? a) private b) local c) global d) public e) protected
Comment on assignment operator in c++.
What is the stack?
How many namespaces are there in c++?
Can I make ios apps with c++?
Differentiate between realloc() and free().
how can u create a doubly linked list with out using pointers?
When should we use container classes instead of arrays?
Can java be faster than c++?
How much is size of struct having 1 char & 1 integer?
Can non graphic characters be used and processed in C++?
How to implement is-a and has-a class relationships?