# sum « Development « C Data Type Q&A

Home
C Data Type Q&A
 1 binary 2 bit 3 byte 4 char 5 character 6 decimal 7 Development 8 float 9 hex 10 integer 11 prime 12 random 13 struct
 C Data Type Q&A » Development » sum

### 1. Finding out the sum of first and the last digit of any number    stackoverflow.com

I want to write a program for finding out the sum of first and the last digit of any number entered through keyboard. For example, I entered 52264. Output must be ...

### 2. Code Golf: Take 2 inputs (number) and print sum in C    stackoverflow.com

We were trying a few crazy things with `c` and came up with this question. Please note that there is nothing important to learn (probably?) from this, but its just for `FUN`. What ...

### 3. How can i find the sum of divisors of a given number in a faster way?    bytes.com

There's a lot of numbers you can easily skip here, you just have to think about the maths behind it. Think about this for instance: "What's the highest divisor I'm ever going to find for a number (excluding the number itself of course)?" If you can calculate this number (or an approximation of it) before the loop, you only have to ...

X

### 8. sum of n natural numbers    cboard.cprogramming.com

Line 6... the user enters an upper limit... say 5 line 7 ... a loop that counts from 0 to the upper limit -1 (0, 1, 2, 3, 4) line 9 ... the value of the loop counter is added to the variable sum. (sum + 0, sum + 1, sum + 2, sum + 3, sum + 4) line 10... ...

### 9. Calculating the sine of a number from the Taylor sum    cboard.cprogramming.com

The error you ask about is probably because you're using factorial (the name of the function) as a variable. You can't assign to the name of a function in C like you can in Pascal. You need to declare a variable for holding the results of your factorial calculations: double fact; Make sure you initialize it before use, probably to 1. ...

### 12. Sum of 2 numbers    cboard.cprogramming.com

\$ gcc bar.c bar.c: In function main: bar.c:9: warning: format %f expects type float *, but argument 2 has type double * bar.c:11: warning: format %f expects type float *, but argument 2 has type double * \$ gcc bar.c \$ ./a.out Type in the first number: 123 Type in the second number: 456 123.000000 + 456.000000 = 579.000000.\$

### 13. Help with entering a number and printing out the Sum    cboard.cprogramming.com

Hi, First I just want to say that this is for homework, but as you can see by the code I have been working on it and got it pretty far. I truly am stuck, I hope this falls within the rules. If not I am sorry. What I need to be able to do is write a program that will ...

### 15. Trouble understanding code to calculate sum of n numbers    cboard.cprogramming.com

Hey all, I am having trouble understanding all of this code to give the sum of n numbers. I think I understand most of it, but there are a few lines which don't make too much sense to me. If anyone could dive deeper into an explanation that would be great! Thanks Code: #include #include int main () { ...

### 17. To get the sum of digits of a five digit number    cboard.cprogramming.com

long time; /* know C? */ Unprecedented performance: Nothing ever ran this slow before. Any sufficiently advanced bug is indistinguishable from a feature. Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31. The best way to accelerate an IBM is at 9.8 m/s/s. recursion (re - cur' - zhun) n. 1. (see recursion)

### 18. ?? with trying to sum numbers    cboard.cprogramming.com

Help, I can't get this program to work correctly. If I put in a number higher or lower than is allowed it gives me the correct error message. However, when I sum up the numbers it is adding them in the total. How do I get the code to not add in the invalid numbers. Code: #include int minimum (int ...

### 20. Sum of n natural numbers    forums.devshed.com

Nice that you started using code tags from the very beginning. However, that desired behavior is negated by your neglecting to indent your code. The idea behind code tags is to preserve your code's indentation so that it will remain readable, so by not indenting your code you're negating the effects of the code tags. Your program works. It does exactly ...

### 21. Help with write c program to find sum of two long numbers    forums.devshed.com

i wrote this program , i didn't understand what the problem... #include #include void main () { int Length1, Length2, i, j, E; char str1[30], str2[30]; int a[30]={0}, b[30]={0}, c[31]={0}; printf("Please Enter the first number\n"); scanf("%s", &str1); printf("Please Enter the second number\n"); scanf("%s", &str2); Length1 = strlen(str1); Length2 = strlen(str2); i=0; while(str1[i] != '\0') { a[30-(Length1-1-i)] = str1[i]; i++; } i=0; ...

### 24. Big numbers: sum and difference    daniweb.com

i need the help of a turbo C master!!!!...one of my final exam problem in my subject has this problem: The Department of mathematics has asked you to develop a program to help elementary students check their addition and subtraction computations. The program to be developed will ask the user for 2 numbers (n1 & n2) and displays the sum (n1+n2) ...