Friday, August 12, 2016

Math Calculator in Cobol

Here is a simple program that I wrote using COBOL to imitate a very simple calculator. The program will ask the user to give two numbers and then our program will compute for the sum, difference, product and quotient of the two numbers given by our user. I am using OpenCOBOLIde as my compiler in this sample program. I hope you will like it. Thank you.


Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.





Sample Program Output


Program Listing

******************************************************************

* Author: MR. JAKE R. POMPERADA

* Date: AUGUST 12, 2016

* Purpose: MATH CALCULATOR IN COBOL

******************************************************************

IDENTIFICATION DIVISION.

PROGRAM-ID. CALCULATOR.

DATA DIVISION.

WORKING-STORAGE SECTION.

77 NUM_1 PIC 9(4).

77 NUM_2 PIC 9(4).

77 SOLVE_SUM PIC 9(4).

77 SOLVE_DIFF PIC 9(4).

77 SOLVE_PRODUCT PIC 9(4).

77 SOLVE_QUOTIENT PIC 9(4).

PROCEDURE DIVISION.

PARA.

DISPLAY "MATH CALCULATOR IN COBOL".

DISPLAY "".

DISPLAY "ENTER THE FIRST VALUE : ".

ACCEPT NUM_1.

DISPLAY "ENTER THE SECOND VALUE : ".

ACCEPT NUM_2.

COMPUTE SOLVE_SUM = NUM_1 + NUM_2.

COMPUTE SOLVE_DIFF = NUM_1 - NUM_2.

COMPUTE SOLVE_PRODUCT = NUM_1 * NUM_2.

COMPUTE SOLVE_QUOTIENT = NUM_1 / NUM_2.

DISPLAY "".

DISPLAY "===== DISPLAY RESULT =====".

DISPLAY "".

DISPLAY "THE SUM IS ".

DISPLAY SOLVE_SUM.

DISPLAY "".

DISPLAY "THE DIFFERENCE IS ".

DISPLAY SOLVE_DIFF.

DISPLAY "".

DISPLAY "THE PRODUCT IS ".

DISPLAY SOLVE_PRODUCT.

DISPLAY "".

DISPLAY "THE QUOTIENT IS ".

DISPLAY SOLVE_QUOTIENT.

STOP RUN.



Hello World in Cobol

Here is a very simple program that I wrote in COBOL to simply display hello world text on the screen.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.


My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing


**********************************************************************
* Author: MR. JAKE R. POMPERADA
* Date: AUGUST 12, 2016 FRIDAY
* Purpose: TO DISPLAY HELLO WORLD ON THE SCREEN
**********************************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID. HELLOWORLD.
DATA DIVISION.
FILE SECTION.
WORKING-STORAGE SECTION.
PROCEDURE DIVISION.
MAIN-PROCEDURE.
DISPLAY "Hello world. Welcome To the Philippines.".
STOP RUN.
END PROGRAM HELLOWORLD.


Addition of Two Numbers in Cobol

Hi there this will be my first time to write a simple program in COBOL or Common Business Oriented Language to find the sum of the two numbers. In this sample program I am using OPENCOBOLIDE as my cobol compiler. The code is very simple and easy to understand.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.


My mobile number here in the Philippines is 09173084360.
 
 

Sample Program Output


Program Listing

******************************************************************
* Author: MR. JAKE R. POMPERADA
* Date: AUGUST 12, 2016
* Purpose: FIND THE SUM OF TWO NUMBERS
******************************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID. ADDITION.
DATA DIVISION.
WORKING-STORAGE SECTION.
77 NUM_1 PIC 9(4).
77 NUM_2 PIC 9(4).
77 SOLVE_SUM PIC 9(4).
PROCEDURE DIVISION.
PARA.
DISPLAY "SUM OF TWO NUMBERS IN COBOL".
DISPLAY "".
DISPLAY "ENTER THE FIRST VALUE : ".
ACCEPT NUM_1.
DISPLAY "ENTER THE SECOND VALUE : ".
ACCEPT NUM_2.
COMPUTE SOLVE_SUM = NUM_1 + NUM_2.
DISPLAY "THE TOTAL SUM IS ".
DISPLAY SOLVE_SUM.
STOP RUN.



 

 

Monday, August 8, 2016

Find the sum of the first 100 Natural Numbers in C++

A simple program that I wrote in C++ to find the sum of the first 100 natural numbers in C++. The code is very easy and use.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing

#include <iostream>


using namespace std;

int main()
{
   int number=0,sum=0;

    cout << "\t Find the sum of the first 100 Natural Numbers ";
    cout << "\n\n";
    for (number =1; number <=100; number++)
    {
        sum+=number;
    }
    cout << "The total sum is " << sum << ".";
    cout << "\n\n";
    cout << "End of Program";
    cout << "\n\n";

}




Find Area of Rhombus in C++

A simple program that I wrote using C++ to find the are of the Rhombus. The code is very easy to understand and use.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing


#include <iostream>
#include <iomanip>

using namespace std;

int main()
{

    float diag_1,diag_2;

    float area=0.00;

    cout << "\t Find Area of Rhombus";
    cout << "\n\n";
    cout << "Enter diagonals of the given rhombus : ";
    cin >> diag_1 >> diag_2;

    area = (0.5 * diag_1 * diag_2);

    cout << "\n\n";
    cout << setprecision(5);
    cout <<"The Area of Rhombus is " << area<<".";
    cout << "\n\n";
    cout << "End of Program";
    cout << "\n\n";

}




Saturday, August 6, 2016

Prime Numbers in Perl

A simple program that I wrote using Perl  to display prime numbers at the screen.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Sample Program Output

Program Listing

#prime.pl

 my @prime_display;

for my $i (2..100){

    my $check="true";
    for (2..$i-1){
       if($i % $_ ==0){
          $check = "false"; 
       }
    }

    if ($check eq "true"){
       push @prime_display, $i;
    }
}
    print "\n\n";
    print "\tPrime Numbers Program in Perl";
    print "\n\n";
    print "List of Prime Numbers";
    print "\n\n";
    print "@prime_display.\n";
    print "\n\n";
    print "\t End of Program";
    print "\n\n";
   


Factorial Number in Perl

A simple program that I wrote using Perl  to display the factorial value of the number.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Sample Program Output

Program Listing

my @factorial = (1);
    $MAX_VALUES=6;
    for my $number (1..$MAX_VALUES) {
        $factorial[$number] = $number * $factorial[$number-1];
    }

    print "\n\n";
    print "\tFactorial Program in Perl";
    print "\n\n";
    for my $values(1..$MAX_VALUES)
    {
    print "The factorial value of $values is $factorial[$values].\n"  ;
  }
   print "\n\n";
   print "\t End of Program";
   print "\n\n";
   


Positive and Negative Number in Perl

A simple program that I wrote using Perl CGI to display positive number and negative number in the web page of the web browser.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.


Sample Program Output

Program Listing

negative.pl


#!"C:\xampp\perl\bin\perl.exe"

print "Content-type:text/html\n\n";
print "<body style='font-family:verdana'>";
print "<font color='blue'>";
print "Positive and Negative Number in Perl";
print "<br><br>";
print "Written By Mr. Jake R. Pomperada, MAED-IT";
print "<br><br>";

print "<table border='1'>";
print "<tr><td>Positive Number</td> <td> Negative Number</td>";
for ($i=1; $i <= 15; $i++) {
print "<tr><td>$i</td>";
print "<td>" ,-$i,"</td> </tr>";

}
print "</table>";
print "</body> </font>";




Cube a Number in Perl

A simple program that I wrote using Perl CGI to display a number and its cube equivalent in the web page of the web browser.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Sample Program Output

Program Listing

cube.pl

#!"C:\xampp\perl\bin\perl.exe"

print "Content-type:text/html\n\n";
print "<body style='font-family:verdana'>";
print "<font color='blue'>";
print "Cube a Number in Perl";
print "<br><br>";
print "Written By Mr. Jake R. Pomperada, MAED-IT";
print "<br><br>";

print "<table border='1'>";
print "<tr><td>Number</td> <td> Cube Equivaelnt</td>";
for ($i=1; $i <= 10; $i++) {
print "<tr><td>$i</td>";
print "<td>" ,$i ** 3,"</td> </tr>";

}
print "</table>";
print "</body> </font>";



Square a Number in Perl CGI

A simple program that I wrote using Perl CGI to display a number and its square equivalent in the web page of the web browser.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

square.cgi

#!"C:\xampp\perl\bin\perl.exe"

print "Content-type:text/html\n\n";
print "<body style='font-family:verdana'>";
print "<font color='blue'>";
print "Square a Number in Perl";
print "<br><br>";
print "Written By Mr. Jake R. Pomperada, MAED-IT";
print "<br><br>";

print "<table border='1'>";
print "<tr><td>Number</td> <td> Square Equivaelnt</td>";
for ($i=1; $i <= 10; $i++) {
print "<tr><td>$i</td>";
print "<td>" ,$i ** 2,"</td> </tr>";

}
print "</table>";
print "</body> </font>";






Repeat Until in Pascal

In this article I would like to share with you a sample program to demonstrate how to use repear loop statement in Pascal. In this sample program I am using Turbo Pascal 5.0 in DOS as my pascal compiler.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing


Program Repeat_Until_Loop;
Uses Crt;

Var A  : Integer;

Begin

  Clrscr;
  Write('Repeat Until Statement in Pascal');
  writeln;
  writeln;

  A := 1;
  Repeat

     Write(' ',A,' ');
     A := A + 1;
  Until (A=11);

   Writeln;
   Writeln;
  A := 10;
  Repeat
    Write(' ',A,' ');
    A := A - 1;
  Until (A=0);


  Readln;
End.


While Loop Statement in Pascal

In this article I would like to share with you a sample program to demonstrate how to use while loop statement in Pascal. In this sample program I am using Turbo Pascal 5.0 in DOS as my pascal compiler.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing


Program While_Loop;
Uses Crt;

Var A  : Integer;

Begin
  Clrscr;
  Write('While Loop Statement in Pascal');
  writeln;
  writeln;
  A := 1;
  While (A<=10) Do
   Begin
     Write(' ',A,' ');
     A := A + 1;
   End;
   Writeln;
   Writeln;
   A := 10;
   While (A>=1) Do
   Begin
     Write(' ',A,' ');
     A := A - 1;
   End;
 
  Readln;
End.


For Loop Statement in Pascal

In this article I would like to share with you a sample program to demonstrate how to use for loop statement in Pascal. In this sample program I am using Turbo Pascal 5.0 in DOS as my pascal compiler.

Add me at Facebook my address is jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing

Program For_Loop;
Uses Crt;

Var A  : Integer;

Begin
  Clrscr;
  Write('For Loop Statement in Pascal');
  writeln;
  writeln;
  For A := 1 to 10 Do
   Begin
     Write(' ',A,' ');
   End;
   Writeln;
   Writeln;
   For A := 10 downto 1 Do 
   Begin
     Write(' ',A,' ');
   End;
 
  Readln;
End.