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 ... |
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 ... |
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 ... |
|
|
|
|
|
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... ... |
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. ... |
|
|
$ 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.$ |
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 ... |
|
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 () { ... |
|
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) |
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 ... |
|
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 ... |
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; ... |
|
|
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) ... |