I never thought I’d say this…

Publicado el 8 March 2012
Archivado en General | Salir del comentario

... but, I think I'm starting to like programming a LOT. I mean, my grade wasn't what I really wanted on my first midterm. I don't blame myself though, I had a lot of stuff to do that week, and my reading-code skills aren't that great right now, but is just that whenever I try to solve a problem by writing a program, and the more I do it, the clearer my thoughts become. These are the kinds of problem I love doing. And, on top of that, this is really practical stuff. I'm pretty sure that the time will come when I can translate everything that I know so far of math to C++. And what's good about it is that I can use it to solve some complex stuff for some people by asking just a little bit of input that I know they can give. Gosh, the more I think about it, the more I like to write code. :|

I got to stop thinking now though, I have to sleep.

Lab 1 results

Publicado el 25 February 2012
Archivado en General | Salir del comentario

Well the lab 1 results were not bad, but I did expect a little better. I knew I missed interpreted the first question, or maybe answered incorrectly. but still not as bad abd I hope the lab 2 results are much better. I really worked hard for it.

Lab 2

Publicado el 25 February 2012
Archivado en General | Salir del comentario

Well, this second lab was let's say, not to difficult yet still not easy. It's a lot of work and I know that the other remaining two are harder and of much work. Well there were some problems I did with ease, and others that were complicated. Well the first problem was easy, but after solving the algorithm and writting the program I had a problem with the while loop, it was not running at all. Well after reviewing  it many times I changed the formula I made to increase the sum of boxes to reach the one metric ton to number_of_boxes++ and it finally ran correctly. The otherone I had problems was with the babylonian algorithm, I had a basic outline for the program but the final program was not being as accurate with the square roots abd I was tired and left it as it is. Mainly I had a little problem with making some of the formulas and the succesful execution of some loops  I used, they where not running. At the end I found the errors and the programs executed correctly, except  fir the accuracy of the babylonian algorithm problem. Now the remaining time is to focus on studying  for tye midterm, at least till the next lab is assigned.

Yes! Found a debugger for Windows!

Publicado el 20 February 2012
Archivado en General | Salir del comentario

Microsoft Visual Studio 2010 Express is my solution. It does everything and the GUI is even beautiful. It's a little weird for the compilation, but it does its work. Got to practice in it a lot though. But I'm so glad I found one that just works.

Bummer!!! I thought I had it right!

Publicado el 20 February 2012
Archivado en General | Salir del comentario

Dang, I think I got something mixed up when I wrote all my codes. Now I got to check all of them.

Note to self: when g++ compiles stuff, at least in what just happened, when there's an int divided by a double variable it results in an int variable. At least that's what happens here in Windows. It screwed up my Moore's Law source code. Bummer. Got check the g++ of Linux though. I really don't know if the compilers work exactly the same, but it seems pretty well like it.


Update: Yeah, it's the same stuff in Linux. I can still compile happily in Windows. I'm so glad that hasn't been taken away from me. 

Testing code for the Babylonian Algorithm

Publicado el 20 February 2012
Archivado en General | Salir del comentario

So, here I was happy until I saw in the lab that I had to compute the square root of a number. Thing is, I'm still to lazy to grab a calculator and put some numbers in it.

So, I searched in Google how to compute it in C++ and I found that I had to include a new source code called "cmath". I tried it and it worked. Here's the source code for testing the sqrt() function from the cmath source code:

Source Code:
 #include <iostream>  
#include <cmath>
using namespace std;

int main()
{

long double number_to_calculate_square_root_of;
char ans;
cout << endl;
cout << "Greetings.\n";

do
{
cout << "Please enter the number you would like\n";
cout << "to calculate the square root of: ";
cin >> number_to_calculate_square_root_of;
cout << "The square root of that number is: " << sqrt(number_to_calculate_square_root_of) << ".\n";

cout << endl;
cout << "Would you like to repeate this process again?";
cout << "Press 'Y' for yes and 'N' for no:";

}while(ans == 'y' || ans == 'Y');

cout << endl;
cout << "Thank you for testing.";
return 0;
}


PS: I'm definitely going to use this for the Babylonian Algorithm just to check that the algorithm is actually approaching the square root of the inputted number.

PPS: My professor did mention this, but he told me he did...


Note to self: Pay MORE attention.

Batch File and Linux Script – Final Version

Publicado el 19 February 2012
Archivado en General | Salir del comentario

Here are the contents of the final batch (*.bat) and linux script file for compiling my source codes.


Batch File:
 @echo off   
echo Compiling and linking C++ source code,
echo and preparing the executable for debugging...
g++.exe -Wall -g -o executable SourceCode.cpp
echo Done


Linux Script:
 echo "Compiling and linking C++ source code,"   
echo "and preparing the executable for debugging..."
g++ -Wall -g -o executable SourceCode.cpp
echo "Done"


PS: I really like their similarities. They are almost the same!
PPS: I got to remember to look for a debugger for the Windows OS later.

MinGW – The Solution! Windows Batch – Updated!

Publicado el 19 February 2012
Archivado en General | Salir del comentario

Success! MinGW compiles and links the source code and prepares the executable for debugging! Here's the new batch file:

@echo off  
echo "Compiling and linking C++ source code,"
echo "and preparing the executable for debugging..."
"C:\MinGW\bin\g++.exe" -Wall -g -o executable SourceCode.cpp
echo "Done"

PS: I can't believe it! No more jumping between operating systems! Now I'm just missing a debugger! I hate Emacs!


PSS: Before I totally forget. By installing MinGW in windows I had to add a new path for the environment variables. (In Windows 7 I can find that by clicking on Start > Right clicking on Computer > Properties > Advanced System Setting > Environment Variables. Then, once I found the "Path" variable, I had only to add a semi-colon at the end of the line ";" and add the desire path, which in this case was "C:\MinGW\bin". I did this because I had an error with libgmp-10.dll. The g++ from the MinGW directory could not find it when I tried to compile my source code. And now that I recall... setting that environment variable that allows me to run g++ directly through the command prompt window, without having to specify its directory. I should update this *.bat file once more.

Windows Batch File – Done!

Publicado el 19 February 2012
Archivado en General | Salir del comentario

It works! Here is the content of the windows batch file (*.bat) I recently created:

@echo off  
echo "Compiling and linking C++ source code..."
"C:\Dev-Cpp\bin\g++.exe" -o executable SourceCode.cpp
echo "Done"

Note: It's basically the same stuff as in linux, the only difference is that I need to turn the echo off for the currently running codes. If I don't do this, the line "C:\Dev-Cpp\bin\g++.exe" -o executable SourceCode.cpp  will show up in the command prompt window.


PS: It doesn't seem possible to prepare the executable for debugging in Windows. I just read something about MinGW, got to check it out... It's a pain to have to reboot every time I need to make programs.

I can compile in Windows!

Publicado el 19 February 2012
Archivado en General | Salir del comentario

Yes! I heard someone mention in the math department that they were programming in something called Bloodshed. I checked it out, and it turns out the program was called DevC++ by Bloodshed. Looks like someone compiled the g++ for the Windows OS. I tried it with one of my problems and voila, it compiled and run perfectly.

Now I just need to make a script... I'm still too lazy to keep writing the same commands all over again in Windows.
« volversige buscando »