I don't know where to start on this one: \n"Write a program that prompts the user to input an integer and then outputs both the individual digits of the number and the sum of the digits.  For example, it should output the individual digits of 3456 as 3 4 5 6, or 8030 as 8 0 3 0, or 2345536 as 2 3 4 5 5 3 6 or -2345 as 2 3 4 5"  \nCan somebody  help me?
206321
the simple program given above if fine.. in terms of the conncept.. but there's a bug... \nthe problem is with looping.. coz when u enter a number such as 80301  or 55302 ( a no. having 0 in between), the loop breaks at the point when zero is encountered.\n\n so the output in the first eg. is  8 0 ,sum= 8 (instead of correct 8 0 3 0 1 , sum=12\n\n\nso the logic of handling the number is absolutely correct but the looping is a comparatively difficult job in this case!
19189
use bitwise operators. something like:\n\nnum_bits = 0;\nfor(i = 0; i < 32; i++) {\nif number & (1<<i) num_bits++;\n}\n\nnow num_bits holds the number of bits that were set in number. The "<<" operator does bit shifting. So "1<<i" equals a number that's all 0's except for a 1 at position i. If you bitwise and that with something, that tells you if that bit is set in the number. So we do this for each of the bits and add up the results.\n\nThis is assuming 32-bit integers. Adjust accordingly for 64-bit integers.
554630
You can generate this in one line of Perl, Unix scripting, or a small C/C++ program.  Simply write one number per line from your program counter.  You may have to get tricky and use two long ints, but it's not hard.\n\n Realize that your document may be very large, and for most purposes, you don't need a document, just use the variable(s) in your final program.
659996
How does this work?  Is it okay to have a decimal in the middle?\n\nType 1   (Screen says 1)\n/ 3          (Screen says 0.3333333)\nx 3         (Screen says 0.9999999)\n+ 9        (Screen says 9.9999999)\n\n- Jack
519525
Hi again Ken,\n\nDid you see my other answer to this similar question?  Did it help any?\n\nIf n is the first of 4 even integers, then the others are:\n\nn+2\nn+4\nn+6\n\nAnd their sum is:\n\nn + n+2 + n+4 + n+6 = 4n + 12\n\nNow, if their sum is 340, then you have the following:\n\n4n + 12 = 340\n4n = 340-12 = 328\nn = 328 ÷ 4 = 82\n\nSo your 4 even integers are:\n\nn = 82\nn+2 = 84\nn+4 = 86\nn+6 = 88\n\nPS - I think the reason you are not getting the answer you want is that the question is worded incorrectly.  Your question states "n is the first 4 even integers" when what I think you mean to say is that "n is the first OF 4 even integers"\n\n~ ♥ ~
596777
Some simple tests to try out first:\n\n1. is the last digit is 5? (divisible by 5)\n\n2. do the digits sum to a multiple of 3? (divisible by 3)\n\n3. add all the digits in even positions (2nd, 4th, etc)\n    add all the digits in odd positions (1st, 3rd, etc)\n    subtract the 2 numbers\n    is this a multiple of 11?\n    e.g. given 9581: (9+8) - (5+1) = 17-6 = 11\n\nIf the answer to any of these is "yes", you have a composite number.\n\nIf not, tought luck! you will have to try dividing it by all odd numbers from 3 to half of the number (well, actually square-root of the number)\n\nAs an aside: try researching the term "recursion"
66092
Just have a variable called max and min\nfor the first number then enter just set that to max and min\nthen for each additional number\nif num > max then max=num\nif num < min and num <> -99 then min=num
51701
Ah, love these kinds of problems.\n\nOK, there is a very efficient solution if you restrict yourself to integer types. Try this code:\n\nint Answer = 0;\nint i;\nfor (i=0; i < 2*n + 1; i++)\n{\n   Answer ^= Array[i];\n}\nprintf ("Single entry is %d&#92;n", Answer);\n\nThe clincher here is that every integer when exclusive ORed with itself yields zero, so all of the duplicates simply disappear - you will only be left with the unpaired entry.
40076
This is kinda wierd without drawing it out, but I'll try to explain and you can come up with the picture.\n\n1)  Start Program\n2)  Accept Input\n3)  Add 1 to counter\n4)  If counter is not equal to 3; go to #2\n5)  If N2 > N3, do #6-8; if not, go to #9\n6)  Move N3 to a hold field\n7)  Move N2 to N3\n8)  Move the hold field to N2\n9)  if N1 > N2, do #6-8 with the N1 & N2 replacing each other\n10) if N2 > N3, do #6-8\n11) print them
494264
Here is a super quick guide to learning to write numbers in binary...\n\nbinary uses 1/0 (on and off) to give value to numbers. This is why it is best used in computer language, because the computer can understand on and off. Now look at the following...\n\n1     \n2      \n4       \n8        \n16    \n32    \n64      \n128   \n\nNow,... notice the above... each number is equil to the number above it x2. this is the basis in learning binary...\n\nlets say we want to write the number  37....  we do the following...(read it from the bottom up)\n\n\n1        (there is one 1 in 1, this leaves us with 0 left over...)\n2        0\n4        (there is one 4 in 5, this leaves us with 1 left over....)\n8        0\n16      0\n32      (there is one 32 in 37, this leaves us with 5 left over...)\n64      0\n128    0\n\n\nso,... in binary, 37 would be   101001  (one 1, one 4, one32)\n\n\nusing the above we can learn to count to 10 !!!\n\n1   (1=1)\n01  (2=2)\n11  (2+1=3)\n001 (4=4)\n101 (4+1=5)\n011 (4+2=6)\n111 (4+2+1=7)\n0001 (8=8)\n1001 (8+1=9)\n0101 (8+2=10)\n\n\n\nthis is a very simple view of binary...\n\n\nhope this helps!!\n\n\n=)
64651
CHOOSE one of the follwing depending upon your course curriculum\n\n\n//Use to following program for multiple calculations in one \n//run.\n\nvoid main()\n{\n\nint a,b; // Declare variables "a" and "b" to get two\n// numbers.\n\n  char Continue = 'Y'; // Declare Continue to loop through \n//the program for multiple calculations. and initialize it \n//to 'Y'\n\n  while(Continue == 'Y' || Continue == 'y') \n// Continue doing the folliwing if the user presses 'Y' for\n// continue.\n  {\n\n  printf("Enter First Number: ");\n  scanf("%d",&a); //scan or get first number\n\n  printf("&#92;nEnter Second Number: ");\n  scanf("%d",&b); //scan or get second number\n\n  printf("&#92;n %d %d  &#92;"DIVISION&#92;" = %f",a,b,(float)a/b); \n// Divide and display the result\n\n  printf("&#92;n %d MOD %d  &#92;"MODULUS&#92;" = %d",a,b,a%b); \n// Calculate Modulus.\n\n  printf("&#92;n&#92;n Do you want to Continue? (Y/N)  :"); \n// Prompt if youser wants to continue.\n  scanf("%s",&Continue);\n\n  printf("&#92;n &#92;n --------------------------------- &#92;n &#92;n"); \n// print saperator between multiple calculations.\n  }\n}\n\n-------------------------------------------------------------------------------------------------------\n\n// Use Following for single calculation in one run...\nvoid main()\n{\n  int a,b; // Declare variables "a" and "b" to get two\n// numbers.\n \n  printf("Enter First Number: ");\n  scanf("%d",&a); //scan or get first number\n  \n  printf("&#92;nEnter Second Number: ");\n  scanf("%d",&b); //scan or get second number\n  \n  printf("&#92;n %d %d  &#92;"DIVISION&#92;" = %f",a,b,(float)a/b); // \n  // Divide and display the result\n  \n  printf("&#92;n %d MOD %d  &#92;"MODULUS&#92;" = %d",a,b,a%b); \n  // Calculate Modulus and print.\n\n}\n\n\nNote: You can not use floats in modulus.
534782
I see two issues, in addition to the division problem pointed out above.  First, you should initialize your variables.  In particular, set sum=0 at the beginning of your code. Do the same for counter.\n\nNext, you have logic issues.  For min and max, you have to initialize these variables, but just setting them to 0 may not work.  If the user enters a series of negative values, you may falsely report 0 as a max. So, the classic solution is to initialize min and max to the first number given by the user.  Of course, this means you'll have to prompt the user for input outside the loop.\n\nBut actually, this helps to solve the other problem.  In particular, when the user enters 0, you still increment your counter. It would be best to redesign your code a little so that the loop condition guarantees that the most recent user value is not zero. You can do this by changing the type of loop that you use, and by asking for the first value outside the loop. \n\nI haven't quite given you all the details, but that's because I want you to think about it yourself.  It'll be a valuable exercise.
93921
you just add the inputs, and the result (the least significant digit) is the answer you need:\n\n0+0+0=0\n0+1+0=1+0+0=0+0+1=1\n1+1+0=0+1+1=1+0+1=10 ->0\n1+1+1=11 ->1\n\nIf you like to solve it by boolean 1+digit adding, then,\nlet you entries be a,b,c\nr1=a.not(b)+b.not(a)\nr=r1.not(c)+c.not(r1)\nwhere . means and
378854
Are you into base system 80? (since you constraint was final 10 digit number.) \nThen it is 80^10.\n\nIf you presume that number 10-80 to be counted as a 2 digit number part of the 10 digit then it gets a bit hairy.
142595
Are you sure you want them *completely* random? Is it acceptable to have, say, 941 + 1 + 1 +... ?\n\nIf so, do something like (in pseudolanguage, my c++ is rusty ;-) :\n\n\nint sum = 1000; //or whatever\nArray allNumbers = EMPTY;\n\nfor (int i = 59; i > 0; i++) {\n  number = Random-between(1, sum - i);\n  push allNumbers, number;\n  sum -= number;\n}\n\n\nSo the first time it gets a result between 1 and 941, say 100.\nNext round, a number between 1 and 842...\nUntil it gets a number between 1 and at-least-1 minus 0.\n\nIf it picked 941 on the first round, say, (sum - i) would be (59 - 58), so a number between 1 and 1 all the way.\n\nThat should do the trick.
452461
Try this...pick a number (say 7)\nsubtract 1 (6)\nsquare (36)\nsubtract 1 (35)\ndivide by original number (5)\nadd 2 (7!)\n\nSteve ;-)
199763
This sounds like school work, its a fairly simple program. you will probably want to use the cout and cin function which needs you to include iostream.h \n\nsimply use cout to print to screen, ask for input etc. then take the input using cin and store it to a int variable.\n\na good way to do it would be to ask the user what they wish to do, eg subtract, divide and take that operator first, a symbol or a number to show choice. then the next line asks for the numbers to be input.\n\neg:\n\n---------\n\nHello. what do you wish to do:\n1 - subtract\n2 - divide\n3 - etc etc\n\n>\n\n-------------\n\nthen use an if function or maybe a switch to check what their input was and do the artithmatic.\n\nso a very basic prgram may look like this:\nit may have errors i havant checked it.\n\n-----------------\n\n#include <iostream>\n\nint main() \n{\nint number;\n\n    cout << "Hello, input a number" << endl;\n    cin >>number;\n    return 0;\n}\n\n------\n\nEDIT; i re read the req, you might find inputting the selection to a char better, then check the char to see what symbol is stored in it, eg + / -. and maybe use a char array for the number input. simple take the char array, check for the space. split the numbers into 2 and caste then to an int. sounds complicated but it isnt to hard.\n\nsorry about spelling mistakes.