Write a function called sort2 that takes in 2 integer values a and b and will swap them if a is greater than b
138457
Assuming this is in C, this is an impossible problem given the main program you provided, because you're passing in the parameters by value rather than by reference.  So any changes you make to those values inside the function will disappear once you return to the main context.\n\nIf you're allowed to change the main program to use pointers, you could do this:\n\nvoid sort2 (int *a, int *b) {\n  int tmp;\n\n  if (*a > *b) {\n   tmp = *a;\n   *a = *b;\n   *b = tmp;\n  }\n}\n\nGiven your main program, you'd call it like this:\n  sort2(&u, &v);\n\nBut it may be that this assignment was given to you specifically to demonstrate that you can't change the value of variables that you pass in by value).
139672
Change 1/2 to a decimal and add it to 11.\n\nChange 1/5 to a decimal and add it to 2.\n\nSubtract the second decimal number from the first.
34052
I do not know a preprogrammed utility to do this, but can point you in the direction that you might need to go.  See the reference below for the math and an on-line converter:
981994
pseudo code sort of, based on C++... easiest for me... I am going to do this with an array of integers because the number of integers read into the program can be different than just three.  This can be easily changed though...\n\nstart program:\n\nint arrayInt[3];  //  places to store three integers\nint largestNumber = 0;  // place to store largest number\ncout << "enter three numbers:  ";   // request for three numbers\nfor (int i = 0; i < 3; i++)\n{     cin >> arrayInt[i]; }    \n// takes the three values from the user's input and stores them in an element in the arrayInt array.\n// so... now you need to compare all of the elements in arrayInt\nfor (int i = 0; i < 3; i++)  // do this three times\n{\n     if ( arrayInt[i] > largestNumber )  \n// comare largestNumber to the current element in the array\n// if it is larger, give largestNumber the value of that element\n     {\n         largestNumber = arrayInt[i] );\n     }\n}\n\n// display the largest number\ncout << "the largest number is:  " << largestNumber << endl;\n\n ******************************************************************\n\n1. initialize variables for the three input integers and a variable to store the largest integer (set this one equal to zero).\n2. ask the user for the three numbers\n3. read the user's input into the variables to store them\n4. compare the values stored in the three variables by either doing it individually (if an array is not used) or with a for loop.  Go through each of the three variables that store the user's input and compare the stored value to the largestNumber variable.  The largestNumber variable should be set equal to 0 since we know that all the numbers will be non negative, therefore 0 is the lowest any of the input numbers can be.  If the value of a variable that stores a user given integer is larger than the largestNumber variable, store the value of the input variable in the largestNumber variable ( largestNumber = inputValue2 ).  As you check all of the three input variables, the largest of all of the values checked will be stored in the largestNumber variable. \n5. tell the user the largest variable
849879
here you go...\n(it'll work with up to 255 different disks, if you need more, you'll have to replace chars with ints)\n\nm1(char *a,b) {memove(b+1,b,strlen(b)+1); *b=*a; memmove(a+1,a, strlen(a);}\nm(char *a,b,c) {if (*a)  {m(a+1,b,c);m1(a,c);m(b,c,a);}
277593
In your case use your fingers bye the way 2+2 = 4
1155261
You can do Binary Searching in two ways \n\n1. Using loops.\n2.Using recurssion.\n\nWhat even,Lets now discuss how it works.\n\nIt works only in a sorted array or in a sorted sequence.\n\nWe are now going to divide the array into two parts using a median or a middle value.Before starting we should need to have a lower bound and an upper bound.\n\nIn starting the lower bound value would be zero and the upper bound value should be no . of elements in the array.\nmedian is always (lowerbound+upperbound)/2\n\n\n\nLet us set the 'median' as mid and the number you want to search as 'num'\n\nAt the first step check mid=num\nIf so the value is found\n\nelse\n\ncheck num<mid\nIf num<mid\nset upperbound = mid\nand find new mid as\n(lowerbound+upperbound)/2\n\nElse if,\nnum> mid\nset lower bound=mid\nand find the new mid value,\nas \nmid=(lowerbound+upperbound)/2\n\n\nAnd contine the process until the value is found or the lowerbound=upperbound(Means no element in the array)\n\n\nI have shown only the concept.\nYou can do it by using loops,Or by using recurrsion.You can use Divide and Conqure method too(recursive  method).
907405
There is a quicksort algorithem built into one of the standard C functions that comes with C++.\n\nIt is called qsort.\n\nYou could also use one of the standard C++ templates. The standard templates have functions to do all sorts of operations.\n\n\nIf you want to program the sort yourself, just write a bubble sort.  See the Wikipedia link for instructions.\n\nIt is not the fastest sort for big datasets but it is more than adequate for even more than 4 numbers at a time.
4293
classic example\nSuppose you want to write a function to exchange the values of two integer variables. It seems like that would be fairly trivial. For example, to swap x and y, you could just create an extra int variable, t, and write code that looks like this: \nt = x;\nx = y;\ny = t;\nThat would certainly work. (Try giving x and y initial values & trace through the code if you don't see why the code works. Note that this approach is similar to what you did for the mandel() function in that programming assignment.)\n\nSo, you would probably suppose that you could write a function like this:\n\nvoid swap (int x, int y) {\n      \n   int t = x;\n      \n   x = y;\n   \n   y = t;\n}\nNow, suppose your main() looks like this:\n\nint main(void)\n{\n   int a = 5;\n   \n   int b = 7;\n      \n   swap( a, b );\n      \n   printf("a is %d and b is %d&#92;n", a, b);\n      \n}\n      \nWhat will print? If swap works, we expect "a is 7 and b is 5" to print. But what actually happens? When the function swap is called, the values of a and b are passed into the functions. When swap begins, x is initialized to 5 and y is initialized to 7. The values of x and y are swapped...but the values of a and b (in main) are unaffected. The swap function does not work as written above because the arguments were passed 'by value.'\n\nWith pointers, we can pass the values 'by reference.' Passing by reference means that we'll pass the addresses of the variables instead of the values. Here's how swap and main should be written:\n\nvoid swap ( int *px, int *py) {\n      \n   int t = *px;\n      \n   *px = *py;\n      \n   *py = t;\n      \n}\n      \nint main(void) \n{\n   int a = 5;\n   \n   int b = 7;\n      \n   swap( &a, &b );\n      \n   printf("a is %d and b is %d&#92;n", a, b);\n      \n}\n      \nNow, the addresses of the variables a and b are passed into swap. In swap, t is set to the value of 'the data that px points to', which is just the value stored at the address of a, which is 5. Then the value stored at address px is changed to the value stored at address py. This sets a to the value of b. Finally, b is set to the value t, which was the value originally stored at a. So, the values of a and b were swapped.
781094
Nobody is going to do your homework for you. \n\nIf you're supposed to write code examples that illustrate how two comparable programs might look, then do this. Write some simple programs in C, and then re-write the same program in C++ but put the functions your void main calls in a class and instantiate the class.
909474
You can do this by hand.\nCall your number x.\nWrite the binary digits of x as b_i :\nx = sum_n=0_n=N b_n.2^n\n\nThe algorithm is simple: compare your number x to the largest power of two (2^N), subtract if necessary, and decrease n until finished (n=0).\n\nStart with n=N , the largest integer such that X >=2^n\nIf x >= 2^n, then {\n b_n = 1;\n x = x-2^n;\n n = n-1; \n} else {\n b_n 0;\n}\n\nThe above is pseudocode, you could do it in C, PERL, Python, Java etc.\n\nSo: x= 121 = 64+57=(64+32)+25=(64+32+16)+9\n=(64+32+16+8)+1 =64+32+16+8+0+0+1\n\nThus 121 (base 10) = 1111001 (base 2)
1120168
Equals another negative number
751233
I'm not sure why you are avoiding the loop, but you could use recursion instead. If I understand your question correctly this function in c++ should give you your desired results.\n\nint sum(int nbr){\n    if(nbr > 0){\n           return(nbr%10 + sum(nbr/10));       \n    }\n    else{\n         return(0);\n    }\n}\n\nIf you called it with a number such as 256, it would return an answer of 13, or the sum of each digit in the integer.
1137758
1) Let's first consider not the combination but the permutations without repetition (considering the order).\n\nSuppose to have 39 numbered cards in your hands and shuffle them well. \nIf you get one card and you drop it on the table you have 39 different possibilities, obviously.\n\nNow, from the remaining 38 cards in your hands, If you drop another card on the right side of the previous card, you'll have 38 different possibilities for just that second choose, but If you consider the order of both cards you'll have exactly 39*38 = 1482 different possibilities that the 2 card will be ordered and choosen in that way.\n\nIf you get a 3rd card from the remaining 37 in your hand you'll have on the table in the right side of previous exraction, a group of 3 ordered cards choosen by 39*38*37 = 54834 different ways will be on the table.\n\nRecursively go to choose until 6 ordered cards will be the table and you'll have 39*38*37*36*35*36 = 2349088560 possibile ways if you consider the order. \n\n2) Now let's see what happend when the order of the selection matters as you asked in your question. \nSo let's make this consideration:\n\na) If you have one card (A) you don't mind about ordering problems:  {A} = (A)\n\nb) if you have two cards (A, B) you have to consider the couple (A, B) = (B, A) so we write {A, B} are commutative;\n\nc) if you have three cards "A", "B" and "C" you can group (A, B) as one element {A, B} because order doesn't matter (point b).\n\nSo we can consider the 3 cards (A, B, C) as:\n ( {A, B}, C ) = ( C, {A, B} ) as we made in the point b.\nYou could also group (A, {B, C}) = ( {B, C}, A)  or {A, C} and then swapping with B.\n\nSo with 3 elements we have 3 different ways to create couple to swap so we can create 3*2 = 6 different combination.\n\nIf we have 4 cards we know it's possible to choose 4 different ways to create list of 3 cards. Let's stop one each time with your finger and you can see that you can group easily the remaining other 3's.\nSo the possible combination with 4 cards is 4 times the possible combination I have with 3 cards. So it's  4 * (3 * 2).\n\nWith 5 cards you'll have 5 times the number of combinations we found with 4 cards, so it's  5 * (4 * 3 * 2).\n\nFinally, with 6 cards in a table arrange in 6 * 5 * 4 * 3 * 2 = 720 different ordered ways.\n\nNow, your question was how to do if the order of selection matters and in the previous example we find that the number of possibilities we have when we select 6 cards ordered is this number 39*38*37*36*35*34 = 2349088560. And we know now that this number is 720 times greater than the possibilities wether the order of selection doesn't matter. (720 = 6 * 5 * 4 * 3 * 2).\n\nIn other words, 39 * 38 * 37 * 36 * 35 * 34 is the number of permutations without repetition of 39 elements grouped by a list of 6 elements considering the order.\n\nAnd now we know with 6 elements you can have 6*5*4*3*2 possible different positions of those elements. \n\nSo Just divide 39*38*37*36*35*34  by 6*5*4*3*2 and you'll have the result of the combinations.\n\nSo to see how many combination of 6 cards bye a set of 39 just divide 39*38*37*36*35*34 / 6*5*4*3*2 = 3262623.\n\nthe number 6*5*4*3*2 could be wrote "6!" using the the factorial function.\n\nThe factorial function of positive integer n, is defined as the product of first n numbers:\n\nn! = 1 * 2 * 3 * ... * n\n\nand is a convention that the product of no numbers at all is 1.\n\n0! = 1\n\n\nThe factorial is also defined recursively by the follow definition:\n\n(n+1)! = (n+1) * n!\n\n\nSo if you have n object and you want to know how many permutation (the order matters) without repetition (each object can be chosen only once) the objects makes with a number k of selection the formula is:\n \n  n! / (n-k)!\n\nso it's the product of k terms starting from n and descending until reached (n-k+1).\n\nn*(n-1)*(n-2)*.
668871
You may have to write that fomula out manually. \n \n=OR(AND(A1,NOT(B1)), AND(NOT(A1),B1))
979933
I'm giving u the program (in C), just go through it, then write the algo. It'll be easier.\n\n// Program :  MERGE  SORT\n\n#include<stdio.h>\n#include<conio.h>\n\nvoid mergesort(int *,int);\n\nvoid main()\n{\nint x[30],n,i;\nclrscr();\nprintf("Enter total no. of elements");\nscanf("%d",&n);\nprintf("Enter %d nos.",n);\nfor(i=0;i<n;i++)\n   scanf("%d",&x[i]);\n\nmergesort(x,n);\n\nprintf("After sorting in descending order :&#92;n");\nfor(i=n-1;i>=0;i--)\n  printf(" %d",x[i]);\n\ngetch();\n}\n\n\n\nvoid mergesort(int x[],int n)\n{\n  int aux[30],l1,l2,u1,u2,i,j,k,size;\n  size=1;   // merges file of size 1\n  while(size<n)\n  {\n    l1=0;   // initialize lower-bound of 1st. file\n    k=0;    // k is index for auxilliary array\n    while(l1+size<n)\n    {\n      // initialize remaining parameters...\n      l2=l1+size;\n      u1=l2-1;\n      u2=(l2+size-1)<n ? (l2+size-1):(n-1);\n      for(i=l1,j=l2;i<=u1 && j<=u2;k++)\n if(x[i]<=x[j])\n   aux[k]=x[i++];\n else\n   aux[k]=x[j++];\n      while(i<=u1)\n      aux[k++]=x[i++];\n      while(j<=u2)\n      aux[k++]=x[j++];\n\n      l1=u2+1;\n    } /* end of 2nd. while-loop */\n    for(i=l1;k<n;i++)\n       aux[k++]=x[i];\n    for(i=0;i<n;i++)\n       x[i]=aux[i];\n\n    size*=2;\n  } /* end of 1st. while-loop */\n}
176472
I'll do it in Visual Basic. You figure out how to convert it.\n\nFunction GradeIsB(intGrade As Integer) As Boolean\nDim blOut As Boolean = False\nIf intGrade >= 80 And intGrade <= 89 Then\nblOut = True\nEnd If\nReturn blOut \nEnd Function\n\nTo use:\n\nDim myGrade As Integer = 87\n\nIf GradeIsB(myGrade) Then\nConsole.Write("It's a B!")\nElse\nConsole.Write("Not a B")\nEnd If