User Profile
Collapse
-
Hi! A function may, or may not, return something to the callee. This "something" might be, coincidentally, one of the arguments the function received when it was called. It is also possible that a function takes no arguments and returns something, for example the rand() function, which generates pseudorandom numbers. -
I just wanted to point that, as far as I know, you can't use the ':' character to name a variable.Leave a comment:
-
Hi! I'm not sure, but this might help: try changing your line of code to
Also, try changing the file encoding to UTF-8.Code:# -*- coding: utf-8 -*-
Leave a comment:
-
Does a Scheme Compiler need a Linker?
Hello, everyone. I have two questions:
1) Does a Scheme compiler need a linker, like in C?
2) Does anyone know of a compiler book (in any programming language and for any programming language) that teaches compiler design including algorithms for generating an executable for Windows?
Thanks in advance! -
If you use malloc, the memory should be freed. At least I think so.Leave a comment:
-
You're welcome. And I forgot: check whether each allocation returns NULL. Also, free all the memory allocated. I think you could do that like this:
Someone please correct me if I'm wrong. Here is a complete program, for a matrix that is 4x4, although it might not be perfect:Code:free( a ); a = NULL; for ( i = 0 ; i < m ; ++i ) { free( *( a + i ) ); *( a + i ) = NULL; }
...Leave a comment:
-
I think the call to prompt should be:
Also, anything the user enters that is not an empty string (or null, if that's possible to be entered) will be considered true.Code:var result = window.prompt( "Want to delete?" )
Leave a comment:
-
Collatz Conjecture
I tried implementing a recursive function for the Collatz conjecture. If the function eventually returns 1, then we have a success. The main function tests the conjecture for all natural numbers between 1 and 1000, including. However, I suspect this recursive solution, even if correct, might be bound to cause a stack overflow. You can read about this conjecture here: http://en.wikipedia.org/wiki/Collatz_conjecture. The program, when executed, printed... -
You're probably getting these errors because a is simply an integer, and not a pointer to pointer. I'm not really sure you can do the following, which also ends up using pointer indirectly:
If this is correct, the memory is allocated at compile time (I think). Other than that, I can't think of other solution. And like I said, the above line might be incorrect - and maybe that depends on the compiler you're...Code:int a[ m ][ n ];
Leave a comment:
-
What are the lines that you're getting errors at? You need a pointer to pointer to hold the address of the first element of the matrix. Assuming you use a, this variable should be declared as:
Allocate the rows with the following statement:Code:int **a;
Then, use a for statement to allocate memory for the columns of each row:Code:a = ( int ** )malloc( m * sizeof( int * ) );
...Code:for ( i = 0 ; i
Leave a comment:
-
stdq replied to Got a C++ programming competition at university. Need a list of programs to practice.in CTry this one too: write a recursive function that receives a positive value in base 10 and prints its binary equivalent.Leave a comment:
-
You use these operators:
+: performs addition.
-: performs subtraction.
*: performs multiplication.
/: performs division.
For example,
declares variable result and assigns 15 to it.Code:int result = 3 * 5;
Leave a comment:
-
Hi! Do you mind posting your code using code tags? Also, in which line(s) is(are) the error(s), according to the compiler/linker?Leave a comment:
-
Hello! www.informit.co m is a nice place for buying books about programming. I suggest you read a book carefully and do its exercises (if there are any) - and, about that, I suggest you pick a book with exercises, because it is important to practice.Leave a comment:
-
stdq replied to I am making an even number game, I used the following code, something seems to be wroin C SharpHi! If you just want to check whether parameter num is even, the following single line can be used in the body of method EvenNumber:
Code:return num % 2;
Leave a comment:
-
How to create a Factorials Table with JavaScript, HTML5 and CSS
Hello, everyone. In this article, I'll show you a way to print a table of the factorials of the integers in the range 0-20. Please note there is no warranty when it comes to using the code here presented. We'll be using JavaScript, HTML5 and CSS. To learn more about factorials, check this link: http://en.wikipedia.org/wiki/Factorial.
The factorial of a positive integer n (n >= 1) is given by the product n * ( n - 1 ) * ( n - 2 )...Last edited by zmbd; May 22 '14, 07:42 PM. -
-
My original code is incorrect. The call to getline should be as follow:
where arg1 is of type char * and arg2 an integer.Code:std::cin.getline(arg1, arg2)
Leave a comment:
-
Interesting. I didn't know about function max_size(). Thanks!Leave a comment:
-
Length of string object
Hi, everyone. Please consider the following code:
In the code above, what is the maximum number of characters that can be read into variable input? Thanks a lot in advance!Code:string input; getline( std::cin, input )
No activity results to display
Show More
Leave a comment: