Sunday, March 19, 2017

One Dimensional Array in Turbo Pascal

In this article I would like to share with you a sample program that will demonstrate how to use one dimensional array using Pascal as our programming language. What does the program will do is to ask the user to give five numbers and then our program will display the list of five numbers given by our user. The code is very simple and easy to understand. I am using Turbo Pascal for Windows as my pascal compiler in this sample program.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.





Sample Program Output


Program Listing

{Written By: Mr. Jake R. Pomperada, MAED-IT }
{Date : March 19, 2017    Sunday            }
{Metro Manila, Philippines                  }
{jakerpomperada@yahoo.com and jakerpomperada@gmail.com }

Program One_Dimensional;
Uses WinCrt;

Type

List_Array = Array[1..6] of Integer;

var val : List_Array;

    b   : Integer;

Begin
clrscr;
 writeln('ONE DIMENSIONAL IN PASCAL');
 writeln;
 for b := 1 to 5 Do
  Begin
     Write('Give value in item no. ' ,b, ' : ');
     Readln(val[b]);
  End;
 Writeln;
 Write('List of Given Values');
 Writeln;
   for b := 1 to 5 Do
  Begin
    Write(' ',val[b],' ');
  End;
 writeln;
 Writeln;
 writeln('  END OF PROGRAM  ');
readln;
End.



Friday, March 17, 2017

Yard To Feet Converter in Turbo Pascal

Here is a sample program that will ask the user to give a value in yard and then our program will convert the given value in yard into feet equivalent using Pascal as our programming language. I use a function to do the conversion from yard to feet by multiplying the value in yard by 3 because 1 yard is equivalent to 3 feet. I hope you will find my work useful. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.






Sample Program Output


Program Listing

Program yard_feet_converter;
Uses WinCrt;

var val_1, solve : integer;

Function convert_feet(a : integer) : integer;
Begin
   convert_feet := (a*3);
End;


Begin
clrscr;
 writeln('YARD TO FEET CONVERTER IN PASCAL');
 writeln;
 Write('Give a value in yard : ');
 Readln(val_1);

 solve:= convert_feet(val_1);

 writeln;
 write('The equivalent value of ' ,val_1, ' yard is ',solve,' feet(s).');
 writeln;
 writeln;
 writeln('  END OF PROGRAM  ');
readln;
End.




Sum of Three Numbers in Pascal

In this article I would like to share with you a sample program that I wrote using Pascal as my programming language that will ask the user to give three numbers and then our program will compute the total sum of three numbers using functions in Pascal. The compiler that I am using in this sample program is Turbo Pascal For Windows. The code is very simple and easy to understand.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.






Sample Program Output


Program Listing

Program Sum_Number;
Uses WinCrt;

var val_1,val_2,val_3, add : integer;

Function sum(a,b,c : integer) : integer;
Begin
   sum := (a+b+c);
End;


Begin
clrscr;
 writeln('SUM OF THREE NUMBERS IN PASCAL');
 writeln;
 Write('Enter First Number : ');
 Readln(val_1);

 Write('Enter Second Number : ');
 Readln(val_2);

 Write('Enter Third Number  : ');
 Readln(val_3);
   
 add := sum(val_1,val_2,val_3);

 writeln;
 write('The sum of ',val_1,' ',val_2, ' and ',val_3, ' is ' ,add,'.');
 writeln;
 writeln;
 writeln('  END OF PROGRAM  ');
readln;
End.


Sum and Product of Two Numbers in Turbo Pascal

In this article I would like to share with you a sample program that will ask the user to give two numbers and then our program will compute the sum and product of the two given numbers using Turbo Pascal for Windows as our compiler. The code uses function to return the computed value. I hope you will find my work useful. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.







Sample Program Output



Program Listing

Program Square_Number;
Uses WinCrt;

var val_1,val_2, add,multiply  : integer;

Function sum(a,b : integer) : integer;
Begin
   sum := (a+b);
End;

Function product(a,b : integer) : integer;
Begin
   product := (a*b);
End;

Begin
clrscr;
 writeln('SUM AND PRODUCT OF TWO NUMBERS IN PASCAL');
 writeln;
 Write('Enter First Number : ');
 Readln(val_1);

 Write('Enter Second Number : ');
 Readln(val_2);
   
 add := sum(val_1,val_2);

 multiply := product(val_1,val_2);
  
 writeln;
 write('The sum of ',val_1, ' and ' ,val_2, ' is ' ,add,'.');
 writeln;
 write('The product of ',val_1, ' and ' ,val_2, ' is ' ,multiply,'.');
 writeln;
 writeln;
 writeln('  END OF PROGRAM  ');
readln;
End.




Square a Number in Turbo Pascal

Here in this article I would like to share with you a sample program that I wrote using Turbo Pascal for Windows to ask the user to give a number and then our program will compute the square value being provided by our user. The program uses functions in Pascal to square the number by the user given.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.






Sample Program Output


Program Listing


Program Square_Number;
Uses WinCrt;

var val, solve  : integer;

Function square(a : integer) : integer;
Begin
   Square := (a*a);
End;


Begin
clrscr;
 writeln('SQUARE A NUMBER IN PASCAL');
 writeln;
 Write('Give a Number : ');
 Readln(val);

 solve := square(val);

 writeln;
 write('The Square value of ' ,val, ' is ' ,solve,'.');
 writeln;
 writeln;
 writeln('  END OF PROGRAM  ');
readln;
End.



Sunday, March 12, 2017

Square and Cube Number in C

In this article I would like to share with you a program that uses for loop statement in  C to generate square and cube number values in C. The code is very simple and easy to understand. I am using CodeBlocks as my text editor and Dev C++ as my C and C++ compiler.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.



Sample Program Output


Program Listing


#include <stdio.h>

int num_value=0;

int main()

{
    printf("\t  SQUARE AND CUBE NUMBER IN C");
    printf("\n\n");
    printf("NUMBER     SQUARE      CUBE\n");
    printf("======     ======      ===== ");
    printf("\n\n");
     for (num_value=1; num_value<=12; num_value++)
     {
         printf("%3d       %4d       %6d\n",num_value,num_value*num_value,num_value*num_value*num_value);
     }
    printf("\n\n");
    printf("\t End of Program ");
    printf("\n\n");
}

Initializer Outside the For Statement in C

In this article I would like to share with you a sample program that will display a series of even numbers using for loop statement in C. The difference in this program is that the initializer is outside the for loop statement in C. The code is very short and easy to understand.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.


My mobile number here in the Philippines is 09173084360.




Sample Program Output


Program Listing


#include <stdio.h>

int main()
{
    int counter=0;
    counter = 2;

    printf("\tInitializer Outside the For Statement in C");
    printf("\n\n");
    for( ; counter <=40; counter = counter +2)
    {
        printf(" %d ",counter);
    }
    printf("\n\n");
    printf("\t End of Program ");
    printf("\n\n");
}




Saturday, March 11, 2017

Addition of Three Numbers in PHP and AJAX

Hi there here is a sample program that will ask the user to give three numbers and then our program will compute the total sum of the three numbers using PHP and AJAX. The code is very simple and easy to understand.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.








Sample Program Output



Program Listing


index.php



<html>
<head>
<title> Addition of Three Number Using PHP and AJAX </title>
</head>
<script language="javascript" src="ajax.js">
</script>
<body>
<style>
body {
background-color:lightgreen;
font-family:arial;
font:12px;
}
</style>
<br>
<h3> Addition of Three Numbers Using PHP and AJAX</h3>
<script>
function clear_all()
{    
   document.getElementById("num1").value= "";
   document.getElementById("num2").value= "";
   document.getElementById("num3").value= "";
}

</script>
<form action="javascript:add(document.getElementById('frm'));" name="frm" id="frm">
<table>
<tr>
<td>First Value</td>
<td>&nbsp;&nbsp;&nbsp;<input id="num1" type="text" autofocus required/></td>
</tr>
<tr>
<td>Second Value</td>
<td>&nbsp;&nbsp;&nbsp;<input id="num2" type="text" required/></td>
</tr>
<tr>
<td>Third Value</td>
<td>&nbsp;&nbsp;&nbsp;<input id="num3" type="text" required/></td>
</tr>
<tr>
<td colspan="2">
<br>
<input type="submit" name="button" value="Solve">
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;
<input type="submit" name="button" value="Clear" onClick="clear_all();">
</td>
</tr>
</table>
</form>
<div name="txt" id="txt"></div>
</body>
</html> 


ajax.js


function add(obj)
{

var XMLHttpRequestObject=false;
if(window.XMLHttpRequest)
{
XMLHttpRequestObject=new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
XMLHttpRequestObject=new ActiveXObject("Microsoft.XMLHTTP");
}

var str1="&num1=" + document.getElementById("num1").value;
var str2="&num2=" + document.getElementById("num2").value;
var str3="&num3=" +document.getElementById("num3").value;

XMLHttpRequestObject.onreadystatechange = show;
XMLHttpRequestObject.open('POST', 'value.php', true);
XMLHttpRequestObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

XMLHttpRequestObject.send(str1+str2+str3);

function show()
{
if (XMLHttpRequestObject.readyState == 4)
{
if (XMLHttpRequestObject.status == 200)
{
result = XMLHttpRequestObject.responseText;
document.getElementById('txt').innerHTML = result;
}
}
}



value.php

<?php
error_reporting(0);
$num1=$_POST['num1'];
$num2=$_POST['num2'];
$num3=$_POST['num3'];
$sum=$num1+$num2+$num3;
echo "The total sum of $num1, $num2 and $num3 is $sum.";
?>







Product of Two Numbers in PHP and AJAX

Hi there in this article I would like to share with you how to you AJAX and PHP together to accept two numbers from the user and then our program will compute the product of the two numbers. The code is written in PHP, JavaScript and AJAX. It is very simple to understand and follow. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.








Sample Program Output


Program Listing

index.php

<html>
<head>
<title> Product of Two Numbers Using PHP and AJAX </title>
</head>
<script language="javascript" src="ajax.js">
</script>
<body>
<style>
body {
background-color:lightgreen;
font-family:arial;
font:12px;
}
</style>
<br>
<h3> Product of Two Numbers Using PHP and AJAX</h3>
<script>
function clear_all()
{    
   document.getElementById("num1").value= "";
   document.getElementById("num2").value= "";
}
</script>
<form action="javascript:product(document.getElementById('frm'));" name="frm" id="frm">
<table>
<tr>
<td>First Value</td>
<td>&nbsp;&nbsp;&nbsp;<input id="num1" type="text" autofocus required/></td>
</tr>
<tr>
<td>Second Value</td>
<td>&nbsp;&nbsp;&nbsp;<input id="num2" type="text" required/></td>
</tr>
<tr>
<td colspan="2">
<br>
<input type="submit" name="button" value="Solve">
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;
<input type="submit" name="button" value="Clear" onClick="clear_all();">
</td>
</tr>
</table>
</form>
<div name="txt" id="txt"></div>
</body>
</html> 

ajax.js


function product(obj)
{

var XMLHttpRequestObject=false;
if(window.XMLHttpRequest)
{
XMLHttpRequestObject=new XMLHttpRequest();
}
else if(window.ActiveXObject)
{
XMLHttpRequestObject=new ActiveXObject("Microsoft.XMLHTTP");
}

var str1= "num1=" + document.getElementById("num1").value;
var str2="&num2=" +document.getElementById("num2").value;

XMLHttpRequestObject.onreadystatechange = show;
XMLHttpRequestObject.open('POST', 'value.php', true);
XMLHttpRequestObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

XMLHttpRequestObject.send(str1+str2);

function show()
{
if (XMLHttpRequestObject.readyState == 4)
{
if (XMLHttpRequestObject.status == 200)
{
result = XMLHttpRequestObject.responseText;
document.getElementById('txt').innerHTML = result;
}
}
}



value.php

<?php
$num1=$_POST['num1'];
$num2=$_POST['num2'];
$num3=$num1*$num2;
echo "The product of $num1 and $num2 is $num3.";
?>


Wednesday, March 8, 2017

Square Root Solver in Visual Basic 6

Hi here is a sample program that will ask the user to give a number in integer and then our program will solve for it's square root equivalent of the given number by the user. The code is very short and easy to understand for beginners that are very new in Visual Basic 6 programming. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.






Sample  Program Output


Program Listing


Function Square_Root_Solver(b As Integer)
Dim num As Integer
num = b
num = num ^ (1 / 2)
Label2.Caption = "The square root value of " & b & _
" is " & num & "."
End Function


Private Sub Command1_Click()
Dim a As Integer

a = Val(Text1.Text)

Call Square_Root_Solver(a)

End Sub

Private Sub Command2_Click()
Label2.Caption = ""
Text1.Text = ""
Text1.SetFocus
End Sub


Square a Number in Visual Basic 6

Hi there in this article I would like to share with you a sample program that will ask you to give a number and then it will compute the square value of the given number the code is very simple and easy to understand.  I hope it will help you understand how to use visual basic 6.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com

My mobile number here in the Philippines is 09173084360.







Sample Program Output


Program Listing


Private Sub Command1_Click()
Dim a As Integer

a = Val(Text1.Text)
square = a * a

Label2.Caption = "The square value of " & a & _
" is " & square & "."

End Sub

Private Sub Command2_Click()
Label2.Caption = ""
Text1.Text = ""
Text1.SetFocus
End Sub