Tuesday, August 13, 2019

Sorting Programs in Turbo Basic

Here is a menu is driven sorting programs in BASIC that I wrote  21 years ago during my college day I used Turbo Basic as my basic compiler in writing, testing and running this program.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com








Sample Program Output


Program Listing


REM NAME OF PROJECT : SORTING TECHNIQUES
REM DATE FINISHED        : SEPTEMBER 19, 1998
REM AUTHOR                   : JAKE RODRIGUEZ POMPERADA

CLS
100
COLOR 10
PRINT
PRINT
FOR C = 1 TO 28
PRINT CHR$(205);
NEXT C
PRINT
print TAB(5) " SORTING TECHNIQUES"
PRINT TAB(8) " MAIN MENU "
FOR C = 1 TO 28
PRINT CHR$(205);
NEXT C
COLOR 11
PRINT
PRINT
PRINT " [1] System Date & Time "
PRINT " [2] Bubble Sort "
Print " [3] Insertion Sort"
PRINT " [4] Selection Sort "
PRINT " [5] Quicksort"
PRINT " [6] Mergesort "
PRINT " [7] Quit / Exit Program"
PRINT " "
FOR C = 1 TO 28
PRINT Chr$(205);
NEXT C
print
input "Enter Your Choice => ",a

IF ( A > 7 OR A < 1) THEN GOTO 105

IF A = 1 THEN
 CLS
 GOTO 110
 END IF

IF A = 2 THEN
  CLS
  GOTO 210
  END IF

IF A = 3 THEN
  CLS
  GOTO 310
  END IF

IF A = 4 THEN
  CLS
  GOTO 410
  END IF

IF A = 5 THEN
  CLS
  GOTO 510
  END IF

IF A = 6 THEN
  CLS
  GOTO 610
  END IF


IF A = 7 THEN
  CLS
 FOR C = 1 TO 75
 PRINT CHR$(205);
 delay .03
 NEXT C
 LOCATE 3,28:  Print "Exit Program To DOS..."
 LOCATE 5,29:  Print "Designed By: Servo"
 FOR C = 1 TO 75
 PRINT CHR$(205);
 delay .03
 NEXT C
 REM  THE KEYWORD SYSTEM EXIT PROGRAM TO DOS !!!
 SYSTEM
 END IF


105
PRINT
FOR C = 1 TO 75
PRINT CHR$(205);
NEXT C
color 31
LOCATE 20,29: PRINT "Invalid Option !!!"
LOCATE 21,23: PRINT "Choose Only Options [1/2/3/4/5/6/7]"
BEEP
FOR C = 1 TO 75
color 11
PRINT CHR$(205);
NEXT C
DELAY 1.5
CLS
GOTO 100

110
CLS
FOR C = 1 TO 28
PRINT CHR$(205);
NEXT C
print
PRINT TAB(3) "SYSTEM DATE AND TIME :"
FOR C = 1 TO 28
PRINT CHR$(205);
NEXT C
print
print
COLOR 15
PRINT "Date :" ,Date$
PRINT "Time :" ,Time$
DELAY 3
CLS
GOTO 100

210
REM BUBBLE SORT MODULE
CLS
DIM A(100)
COLOR 15
FOR F = 1 TO 20
PRINT "=";
NEXT F
PRINT
PRINT " BUBBLE SORT MODULE"
FOR G = 1 TO 20
PRINT "=";
NEXT G
PRINT
PRINT
Input "How many inputs :",A
FOR I = 1 To A
PRINT "Item #";i;
INPUT A(i)
NEXT I
Let N = I - 1
For J = 1 To N - 1
For I = 1 To N-J
If a(i) <= A(i+1) then 270
Let T=A(I)
Let A(i)=A(i+1)
Let A(i+1)=T
270 Next I
Next J
print
print " Sorted List of";a; "items"
PRINT
For I = 1 To N
Print a(i)" ";
next I
delay 3
cls
goto 100
end

310
REM INSERTION SORT MODULE
CLS
Dim B(100)
COLOR 15
FOR F = 1 TO 22
PRINT "=";
NEXT F
PRINT
PRINT "INSERTION SORT MODULE"
FOR F = 1 TO 22
PRINT "=";
NEXT F
PRINT
PRINT
Input "How many inputs :",a
for i = 1 To a
print "Item #";i;
input B(i)
next i
Let N = I - 1
For I = 1 To N - 1
Let J = I
Let T = B(I+1)
540 If J < 1 then 590
IF T >= B(J) THEN 590
Let B(J+1)=B(J)
Let J = J -1
Goto 540
590 Let B(J+1)=T
Next I
Print
print " Sorted List of";a; "items"
PRINT
For I = 1 To N
Print B(i)" ";
NEXT I
DELAY 3
CLS
GOTO 100
END

410
REM SELECTION SORT MODULE
CLS
DIM L(100)
COLOR 15
FOR F = 1 TO 23
PRINT "=";
NEXT F
PRINT
PRINT "SELECTION SORT MODULE"
FOR F = 1 TO 23
PRINT "=";
NEXT F
PRINT
PRINT
Input "How many inputs :",a
for i = 1 To a
print "Item #";i;
input L(i)
next i
Let N = I - 1
FOR I = 1 TO N - 1
FOR J = I + 1 TO N
IF L(J) >= L(I) THEN 330
LET Q = L(J)
LET L(J)=L(I)
LET L(I) = Q
330 NEXT J
NEXT I
PRINT
PRINT " Sorted List of";a; "items"
PRINT
For I = 1 To N
PRINT L(i)" ";
NEXT I
delay 3
cls
GOTO 100
END

510
REM QUICKSORT MODULE
CLS
Dim S(100)
COLOR 15
FOR F = 1 TO 22
PRINT "=";
NEXT F
PRINT
PRINT TAB(3) "QUICKSORT MODULE"
FOR F = 1 TO 22
PRINT "=";
NEXT F
PRINT
PRINT

PRINT "How many inputs :";
INPUT V
for R = 1 To V
print "Item #";R;
INPUT S(R)
next R
for O = 1 TO V - 1
FOR I = O + 1 TO V
IF  S(I) >=  S(O) THEN 130
LET C = S(O)
LET S(O) = S(I)
LET S(I) = C
130 NEXT I
    NEXT O
PRINT
PRINT " Sorted List of";V "items"
PRINT
FOR F = 1 TO V
PRINT S(F);
NEXT F
delay 3
cls
GOTO 100
END

610
REM MERGESORT MODULE
CLS
DIM X(100)
COLOR 15
FOR F = 1 TO 20
PRINT "=";
NEXT F
PRINT
PRINT " MERGESORT MODULE"
FOR F = 1 TO 20
PRINT "=";
NEXT F
PRINT
PRINT
Input "How many inputs :",a
for i = 1 To A
PRINT "Item #";i;
INPUT X(i)
next i
LET N = I - 1
For J = 1 To N - 1
For I = 1 To N-J
If X(i) <= X(i+1) then 970
Let T=X(I)
LET X(i)=X(i+1)
LET X(i+1)=T
970 Next I
Next J
PRINT
PRINT " Sorted List of";a; "items"
PRINT
For I = 1 To N
PRINT X(I)" ";
NEXT I
DELAY 3
CLS
GOTO 100
END

1000 END



Addition of Three Numbers in QBasic

In this article, I would like to share with you guys a simple program that I wrote using Quick Basic in DOS to ask the user to give three numbers and then the program will compute the sum of the three numbers and display the results in the screen.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com



Sample Program Output


Program Listing

PRINT
PRINT "Addition of Three Numbers in QBasic"
PRINT
INPUT "Give First  Value : ", a
INPUT "Give Second Value : ", b
INPUT "Give Third Value  : ", c
PRINT
sum = (a + b + c)
PRINT "The sum of"; a, ","; b; "and"; c; "is"; sum; "."
PRINT
PRINT "End of Program"
PRINT




Sunday, August 11, 2019

Product of Two Numbers Using One Dimensional Array in C

Here is a simple program to compute the product of two numbers using One Dimensional Array in C.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com



Program Listing

#include <iostream>

 using namespace std;

 int product(int a, int b)
 {
     return(a*b);
 }


  main() {
      int num[2];

      cout << "enter two value : ";
      cin >> num[0] >> num[1];
      cout << "The product of "
           << num[0] << " and "
           << num[1] << " is "
           << product(num[0],num[1])
           << "." << endl;

     system("pause");
  }


Number To Words Converter in C

A simple number to words converter in C programming language.


I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com


Program Listing

number_words.c

#include<string.h>
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<math.h>


final_resort(long int num);
onebillion(long int x);
hundredmillion(long int x);
tenmillion(long int x);
onemillion(long int x);
hundredthou(long int x);
tenthou(long int x);
onethou(long int x);
hundred(long int x);
ten(long int x);
teen(int x);
one(int x);
char temp[200]=" ";
long int num;
void main(void)

{



printf("\t\t NUMBER TO WORDS CONVERTER IN C");
printf("\n\nGive a  Number: ");
scanf("%ld",&num);
printf("\n");
if (num<1412999999&&num>=1)

{
final_resort(num);

printf("In Words: %s",temp);
}
else if(num>=1412999999)
{
printf("\nError: Input Value must be less than 1,412,999,999!");
}
else {
printf("Error: Cannot convert the inputed value!" );

}

getch();
}

//last resort
final_resort(long int num)
{
char str1[20];
int lengs;
sprintf(str1,"%ld",num);
lengs=strlen(str1);
switch (lengs)
{
case 1:
one(num);
break;

case 2:
ten(num);
break;

case 3:
hundred(num);
break;

case 4:
onethou(num);
break;

case 5:
tenthou(num);
break;

case 6:
hundredthou(num);
break;
case 7:
onemillion(num);
break;

case 8:
tenmillion(num);
break;

case 9:
hundredmillion(num);
break;

case 10:
onebillion(num);
break;

}


}



//one

one(int x)
{
switch (x)
{
case 1:
strcat(temp,"one ");
break;

case 2:
strcat(temp,"two ");
break;

case 3:
strcat(temp,"three ");
break;

case 4:
strcat(temp,"four ");
break;

case 5:
strcat(temp,"five ");
break;

case 6:
strcat(temp,"six ");
break;

case 7:
strcat(temp,"seven ");
break;

case 8:
strcat(temp,"eight ");
break;

case 9:
strcat(temp,"nine ");
break;


}

}

//teens


teen(int x)
{
switch (x)
{
case 10:
strcat(temp,"ten ");
break;

case 11:
strcat(temp,"eleven ");
break;

case 12:
strcat(temp,"twelve ");
break;

case 13:
strcat(temp,"thirteen ");
break;

case 14:
strcat(temp,"fourteen ");
break;

case 15:
strcat(temp,"fifteen ");
break;

case 16:
strcat(temp,"sixteen ");
break;

case 17:
strcat(temp,"seventeen ");
break;

case 18:
strcat(temp,"eighteen ");
break;

case 19:
strcat(temp,"nineteen ");
break;


}

}

//ten

ten(long int x)
{
long int q,m;

q=x/10;
m=x%10;

switch (q)
{

case 2:
strcat(temp,"twenty ");
one(m);
break;

case 3:
strcat(temp,"thirty ");
one(m);
break;

case 4:
strcat(temp,"fourty ");
one(m);
break;

case 5:
strcat(temp,"fifty ");
one(m);
break;

case 6:
strcat(temp,"sixty ");
one(m);
break;

case 7:
strcat(temp,"seventy ");
one(m);
break;

case 8:
strcat(temp,"eighty ");
one(m);
break;

case 9:
strcat(temp,"ninety ");
one(m);
break;

}

if (x>=10&&x<=19)
{
teen(x);
}
else if (x>=1&&x<=9)
{
one(x);
}


}

//hundred

hundred(long int x)
{

long int q2,p2,d2;
q2=x/100;
p2=q2*100;
d2=x-p2;

switch (q2)
{
case 1:
one(q2);
strcat(temp,"hundred ");
ten(d2);
break;

case 2:
one(q2);
strcat(temp,"hundred ");
ten(d2);
break;

case 3:
one(q2);
strcat(temp,"hundred ");
ten(d2);
break;

case 4:
one(q2);
strcat(temp,"hundred ");
ten(d2);
break;

case 5:
one(q2);
strcat(temp,"hundred ");
ten(d2);
break;

case 6:
one(q2);
strcat(temp,"hundred ");
ten(d2);
break;

case 7:
one(q2);
strcat(temp,"hundred ");
ten(d2);
break;

case 8:
one(q2);
strcat(temp,"hundred ");
ten(d2);
break;

case 9:
one(q2);
strcat(temp,"hundred ");
ten(d2);
break;


}
if (q2<=0)
{
ten(x);
}

}

//thousands
onethou(long int x)

{

long int q1,p1,d1;

q1=x/1000;
p1=q1*1000;
d1=x-p1;
one(q1);
strcat(temp,"thousand ");
hundred(d1);

}
//tenthousands

tenthou(long int x)
{
long int q1,m;
q1=x/1000;
m=x%1000;
ten(q1);
strcat(temp,"thousand ");
hundred(m);

}

//hundredthousand

hundredthou(long int x)
{
long int q1,q2;
long int m1,m2;
q1=x/100000;
m1=x%100000;
one(q1);
strcat(temp,"hundred ");
q2=m1/1000;
m2=m1%1000;
ten(q2);
strcat(temp,"thousand ");
hundred(m2);

}

//one million

onemillion(long int x)
{
long int q1,q2;
long int m1,m2;
q1=x/1000000;
m1=x%1000000;
one(q1);
strcat(temp,"million ");
q2=m1/1000;
m2=m1%1000;
hundred(q2);
if (q2!=0)
{
strcat(temp,"thousand ");
}

hundred(m2);

}

//ten million

tenmillion(long int x)
{
long int q1,q2;
long int m1,m2;
q1=x/1000000;
m1=x%1000000;
ten(q1);
strcat(temp,"million ");
q2=m1/1000;
m2=m1%1000;
hundred(q2);
if (q2!=0)
{
strcat(temp,"thousand ");
}

hundred(m2);

}

//hundred million

hundredmillion(long int x)
{
long int q1,q2;
long int m1,m2;
q1=x/1000000;
m1=x%1000000;
hundred(q1);
strcat(temp,"million ");
q2=m1/1000;
m2=m1%1000;
hundred(q2);
if (q2!=0)
{
strcat(temp,"thousand ");
}

hundred(m2);

}
//onebillion
onebillion(long int x)
{
long int q1,q2,q3;
long int m1,m2,m3;
q1=x/1000000000;
m1=x%1000000000;
one(q1);
strcat(temp,"billion ");
q2=m1/1000000;
m2=m1%1000000;

hundred(q2);
if (q2!=0)
{
strcat(temp,"million ");
}

q3=m2/1000;
m3=m2%1000;
hundred(q3);

if (q3!=0)
{
strcat(temp,"thousand ");
}

hundred(m3);

}



Sorting of Three Numbers in C++

A simple program that I wrote a long time ago to ask the user to give three numbers and then the program will sort the three numbers using C++ as our programming language.


I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com


C++ Compiler and IDE that I used in writing this program Code Blocks



Sample Program Output

Program Listing


#include <iostream>

using namespace std;

int main(){

   int a=0, b=0, c=0;
   cout << "\t <====== SORTING THREE NUMBERS =====>";
   cout << "\n\n";
   cout<<"Please Enter Three Numbers :=> ";
   cin>>a>>b>>c;
   cout << "\n\n";
   cout<<"Numbers sorted in Ascending Order : ";
   if(a<b){

        if(a<c){
            cout<<a<<", ";

            if(c<b)
            cout<<c<<", "<<b<<"\n";
            else cout<<b<<", "<<c<<"\n";
        }
        else{
             cout<<c<<", ";
           if(a<b) cout<<a<<", "<<b<<"\n";
            else cout<<b<<", "<<a<<"\n";
        }
    }
    else{

        if(b<c){

            cout<<b<<", ";

           if(a<c) cout<<a<<", "<<c<<"\n";
            else cout<<c<<", "<<a<<"\n";
        }
        else{
             cout<<c<<", ";

           if(a<b) cout<<a<<", "<<c<<"\n";
            else cout<<b<<", "<<a<<"\n";
        }
    }
   cout << "\n\n";
   cout << "THANK YOU FOR USING THIS PROGRAM";
   cout << "\n\n";
   system("pause");
}





Function Parameters in C

Here is a simple code to show you how to use function parameters in C programming language.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My personal website is http://www.jakerpomperada.com


Program Listing

#include <stdio.h>
#include <stdlib.h>

// declaration of function prototype

void hello(char user[50]);
// function with parameters

main()
{
system("cls");
// Calling the function with
// parameters
hello("John Smith");

printf("\n\n");
system("pause");
}

void hello(char user[50])
{
 printf("\t     Hello %s" ,user, ".");
 printf("\n\n");
 printf("\tWelcome To Bacolod City");
}