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.

Year Level Checker in Pascal

A simple program that I wrote in Pascal to check if the given year level of the student belongs to freshmen, sophomore, junior, seniors or invalid year level. The code is very simple and easy to understand I am using Turbo Pascal 5.0 for DOS in this sample program.

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 Year_Level;
Uses Crt;

Var year_level_students  : Integer;

Begin
  Clrscr;
  Write('Year Level Checker in Pascal');
  writeln;
  writeln;
  Write('Give the year level of the student :');
  readln(year_level_students);

  if (year_level_students = 1) then
    Begin
    Writeln;
    Writeln('You are belong to Freshmen.');
    End
  else if (year_level_students = 2) then
    Begin
    Writeln;
    Writeln('You are belong to Sophomore.');
    End
  else if (year_level_students = 3) then
    Begin
    Writeln;
    Writeln('You are belong to Juniors.');
    End
  else if (year_level_students = 4) then
    Begin
    Writeln;
    Writeln('You are belong to Seniors.');
    End
  else
     Begin
     Writeln;
     Writeln('Invalid Year Level Try Again.');
     End;
  Readln;
End.

Age Checker in Pascal

In this article I would like to share with you a sample program that I wrote in Pascal to check if the given age of the user is already considered as an Adult or still a minor. I am using Turbo Pascal 5.0 as my compiler in this sample program.

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 Age;
Uses Crt;

Var Age_User  : Integer;

Begin
  Clrscr;
  Write('Age Checker in Pascal');
  writeln;
  writeln;
  Write('What is your age? ');
  readln(Age_User);

  if (Age_User >=18) then
    Begin
    Writeln;
    Writeln(Age_User, ' years old. You are already an Adult.');
    End
  else
     Begin
     Writeln;
     Writeln(Age_User, ' years old. You are still a Minor.');
     End;
  Readln;
End.

Positive and Negative Number Checker in Pascal

Hi there in this article I would like to share with you a sample program that I wrote using Pascal as my programming language to check if the given number by the user is a positive or negative number. In this sample program I am using Turbo Pascal 5.0 as my 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 Positive_Negative;
Uses Crt;

Var Number : Integer;

Begin
  Clrscr;
  Write('Positive and Negative Number Checker');
  writeln;
  writeln;
  Write('Enter a Number : ');
  readln(Number);

  if (number >=0) then
    Begin
    Writeln;
    Writeln(Number, ' is a Positive Number.');
    End
  else
     Begin
     Writeln;
     Writeln(Number, ' is a Negative Number.');
     End;
  Readln;
End.

Friday, August 5, 2016

Lower Case To Upper Case Converter in C++

A simple program that I wrote in C++ to covert lowercase to uppercase of string in C++.

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

My mobile number here in the Philippines is 09173084360.


Program Listing

#include <iostream>
#include <cctype>
#include <string>


int main()
{
    using namespace std;
    string str;

   cout << " Lower Case To Upper Case String Conversion 1.0";
   cout << "\n\n";
   cout << "Enter a String : ";
   getline(cin,str);
    for (size_t i = 0; i < str.length(); ++i)
    {
        str[i]=toupper(str[i]);
    }

    cout << "\n";
    cout<<"\n Converted Results in Upper Case : "  <<str << ".";
    for (size_t i = 0; i < str.length(); ++i)
    {
        str[i]=tolower(str[i]);
    }

    cout<<"\n Converted Results in Lower Case : "  <<str << ".";
    cout << "\n\n";
    system("PAUSE");

}

Addition of Five Numbers in Perl CGI

A sample program that I wrote that will compute the sum of the five numbers using Perl CGI it will display the result in the web page in your 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

#!"C:\xampp\perl\bin\perl.exe"
print "content-type: text/html \n\n";
print "<html>";
print "<body>";

$a=2;
$b=3;
$c=5;
$d =3;
$e = 2;

$sum = ($a + $b + $c + $d + $e);

print "<font color='blue'>";
print "<br>";
print " <h2> Addition of Five Numbers </h2>";
print "<font size='5'>The value in A is $a. </font><br>";
print "<font size='5'>The value in B is $b. </font><br>";
print "<font size='5'>The value in C is $c. </font><br>";
print "<font size='5'>The value in D is $d. </font><br>";
print "<font size='5'>The value in E is $e. </font><br>";

print "<br><br>";
print "<font size='5'>The sum of $a ,$b , $c, $d and $e is $sum. </font>";
print "</font>";
print "</body>";
print "</html>";


# test.pl
# if you are using xampp with installed perl interpreter
# save your file for example test.pl in the following 
# directories in xampp.  example  c:\xampp\cgi-bin\test.pl
# to run the script.
# Issue this command for example
#
# localhost:1234/cgi-bin/test.pl
##








HTML Form in Perl CGI

A simple program that I wrote in Perl CGI to show how to use HTML FORM to capture the user input and display the result in the same page. 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

#!"C:\xampp\perl\bin\perl.exe"
use strict;
use warnings;
use CGI qw(:all);

my $cgi = new CGI;
my $this_url = $cgi->url(); 
my $first = $cgi->param('first_name');
my $last = $cgi->param('last_name');
print "Content-type:text/html\n\n";
print <<EndOfHTML;
<html><head><title>Perl Same Page Display</title></head>
<style>
  body {
   font-family: arial;
   font-size: 18px;
   font-weight: bold;
 };
</style>
<body>
<FORM action="$this_url" method="POST">
<font color='green'>
What is your first name <input type="text" name="first_name" value='$first'>  <br>
What is you last name  <input type="text" name="last_name" value='$last'>
<br><br>
<input type="submit" value="Ok">
</FORM>
<p>Hello $first $last How are you today?</p> </font>
</body>
EndOfHTML