Tuesday, April 22, 2008

Factorial n!(Logic in Programming)

During my College life as a computer science, I have encountered Factorial problems often at programming. I just want to share this, hope it help.

In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example,

For example:

5! = 1 x 2 x 3 x 4 x 5 = 120


In Programming:

Note: 0! = 1

N = input;

ANS=1;

For ( ctr = N; ctr >=1; ctr--)
{
ANS = ANS * ctr;
}

PRINT(“Total: ” + ANS);

Wednesday, March 5, 2008

Nested For-loop using Java

I took an exam from one of the Japanese company here in the Philippines for the programmer’s trainee position, and then the programming part is the same as this problem that you can use C or Java programming, depends to our knowledge.

I know that this problem is very easy, because I’ve encountered this problem when I was a first year college student using C language, but whyyyy I can’t answer this simple problem during that exam, well the result is failed, (lol), because of that incident, and because of my stupidity I tried this problem into my own computer, then I got it right (sad). I’m working for almost 8 months as a junior programmer, but then I didn’t pass that exam. (I think, because I didn’t get any proper training at all, or maybe I’m just really stupid), well there is always another chance :P.


1. Code: Try4.java

class Try4{

public static void main(String[] args){

for(int ctr=0;ctr<6;ctr++){

for(int ctr2=4;ctr2>=ctr;ctr2--){

System.out.print("* ");

}

for(int ctr3=0;ctr3<=ctr;ctr3++){

System.out.print("@ ");

}

System.out.println(" ");

}

for(int ct=0;ct<5;ct++){

for(int ct2=0;ct2<=ct;ct2++){

System.out.print("* ");

}

for(int ct3=4;ct3>=ct;ct3--){

System.out.print("@ ");

}

System.out.println(" ");

}

}

}






2. Code: Try3.java

class Try3{

public static void main(String[] args){

for(int ctr=0;ctr<10;ctr++){

for(int ctr2=8;ctr2>=ctr;ctr2--){

System.out.print("* ");

}

for(int ctr3=0;ctr3<=ctr;ctr3++){

System.out.print("@ ");

System.out.print(" ");

}

System.out.println(" ");

}

}

}




3. Code: Try2.java

class Try2{

public static void main(String[] args){

for(int ctr=0;ctr<10;ctr++){

for(int ctr2=1;ctr2<=ctr;ctr2++){

System.out.print(" ");

System.out.print(" ");

}

for(int ctr3=9;ctr3>=ctr;ctr3--){

System.out.print("* ");

}

System.out.println(" ");

}

}

}




4. Code: Try.java

class Try{

public static void main(String[] args){

for(int ctr=0;ctr<10;ctr++){

for(int ctr2=8;ctr2>=ctr;ctr2--){

System.out.print(" ");

System.out.print(" ");

}

for(int ctr3=0;ctr3<=ctr;ctr3++){

System.out.print("* ");

}

System.out.println(" ");

}

}

}




5. Code: Triangle.java

class Triangle{

public static void main(String[] args){

for(int ctr=0;ctr<10;ctr++){

for(int ctr2=9;ctr2>=ctr;ctr2--){

System.out.print(" ");

}

for(int ctr3=0;ctr3<=ctr;ctr3++){

System.out.print("@ ");

}

System.out.println(" ");

}

}

}




6. Code: Square2.java

class Square2{

public static void main(String[] args){

for(int ctr=0;ctr<10;ctr++){

for(int ctr2=0;ctr2<=ctr;ctr2++){

System.out.print("@ ");

}

for(int ctr3=9;ctr3>=ctr;ctr3--){

System.out.print("* ");

}

System.out.println(" ");

}

}

}




7. Code: Square.java

class Square{

public static void main(String[] args){

for(int ctr=0;ctr<10;ctr++){

for(int ctr2=9;ctr2>=ctr;ctr2--){

System.out.print("* ");

}

for(int ctr3=0;ctr3<=ctr;ctr3++){

System.out.print("@ ");

}

System.out.println(" ");

}

}

}




8. Code: Sample2.java

class Sample2{

public static void main(String[] args){

for(int ctr=0;ctr<10;ctr++){

for(int ctr2=9;ctr2>=ctr;ctr2--){

System.out.print("* ");

}

System.out.println(" ");

}

}

}




9. Code: Sample.java

class Sample{

public static void main(String[] args){

for(int ctr=0;ctr<10;ctr++){

for(int ctr2=0;ctr2<=ctr;ctr2++){

System.out.print("* ");

}

System.out.println(" ");

}

}

}


Tuesday, February 26, 2008

Generic Host Process for Win32 error of Windows XP SP2

I've encountered this problem when I uninstalled my antivirus.

The result of this message when it popped up is that I can’t play any media sounds; it says that the codec and other media devices have been disabled. So I’ve tried to re-install my sound card driver, etc. but suddenly after restarting my computer, the message has popped up again.

So I don’t have any option, but surfing the internet and finally found the following solution.

(I wound like to apologize to the anonymous sources of the following solution; because I forgot to get your name coz I’ve searched the following solution from my computer at my office.) But thank you so much.

Solution:

You need to turn off or disabled your internet connection for doing the following solution.


  1. Open My Computer>Tools>Folder Options>View (Tab)>Hidden Files & Folders>Show Hidden Files and Folders>OK
  2. When I checked/examined the window message I’ve found the following.

C:\DOCUME~1\Account_Name\LOCALS~1\Temp\WER731e.dir00\svchost.exe.mdmp

C:\DOCUME~1\Account_Name\LOCALS~1\Temp\WER731e.dir00\appcompat.txt

So you need to delete the folder WER731e.dir00.

Next

1. Turn on your Windows Firewall, and turn off Automatic Updates. Even though you have turned this thing off, you still have to follow the next steps.

2. Right-click My Computer and click Services. If you want the long way around, go to Control Panel, double-click Administrative Tools, and then double click Services.

3. Double-click Automatic Updates.

4. If it is running, click Stop.

5. On the Startup Type drop-down menu, select Disabled.

6. Click Apply, and then click OK.

Next

1. Start Registry Editor (Regedit.exe) by clicking Start menu, and then click the Run icon.

2. In the small box that Opens, type: regedit then click the OK button. The Registry Editor will now have opened.

3. Locate the following key in the registry:

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\NetBT\Parameters

In the right-hand side of the window find an option called TransportBindName.

Double click that value, and then delete the default value, thus giving it a blank value.

Next

1. Then you must now navigate to the following registry key:

HKEY_LOCAL_MACHINE\Software\Microsoft\OLE

2. You will see there is a String Value called: EnableDCOM

Set the value to: N (it should currently be Y)

3. Close the Registry Editor. Restart your computer.


Hopefully these solutions will help you fix this windows problem.

Monday, February 11, 2008

PLDT Phone Security Code

I've Searched for this security code to ensure that my phone will not gonna use by some phone abusers coz I'm the one who's paying the monthly bill.

Direct Distance Dial

PLDT DDD Security Code allows you to lock or unlock your DDD thereby limiting instances of unauthorized long distance usage.

To use, simply lift the handset and:

To lock: press *54* and your 4-digit code then press #
To unlock: press #54* and your 4-digit code then press #
To change code: press *85* and your present 4-digit code then press *
and your new desired 4-digit code then press #

reminder:
1. Your initial code is 1234. We recommend that you change this immediately.
2. Wait for the confirmation message or tone to know if your instruction has been accepted.
3. Keep your code confidential.
4. Always lock your DDD after the call.
5. Your phone should be on “tone” mode.

Source: http://www.pldt.com.ph/prod-serv/home/ddd.htm