Tuesday, January 8, 2019

Login Using a Text File in C

While I'm writing my book on C programming I came across with the idea to include in my book topic on File Handling in C.  The idea is to write a program using C as my programming language to store a username and password in a text file and create a login program that will ask the user to give the username and password. The program will search for the username and password that is already stored in our text file. In this example the name of the text file is users.txt. I

If the username and password are correct and can be located in the text file the program will allow the user to access the system. But if username or password is incorrect the program will not allow the user to access the system. I hope you will find my work useful.  Thank you.

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

/* login.c 
 Author    : Jake Rodriguez Pomperada,MAED-IT 
 Website   : http://www.jakerpomperada.com
 Emails    : jakerpomperada@gmail.com and jakerpomperada@aol.com
 Location  : Bacolod City, Negros Occidental
 Tool      : Dev C++ Version 5.11
 Date      : January 7, 2019   3:46 PM Monday
*/

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

void get_ID_and_PASS(char fileName[30],char *id,char *pass)
{
    FILE *F = fopen(fileName,"r");

    if(F)
    {
        int count = 0;
        while(!feof(F))
        {
            char rawLine[50];
            fscanf(F,"%s",rawLine);
            if(!count++)
                strcpy(id,rawLine);
            else
                strcpy(pass,rawLine);

        }
    }else printf("Cannot open this file");
    fclose(F);
}

int main()
{
    char fileName[30] = "users.txt";
    char userID[50],userPassW[50];
    char strID[50]="\0",strPASSW[50]="\0";
    char IDpref[50] = "user_id:\0",PASSWpref[50] = "password:\0";
    get_ID_and_PASS(fileName,userID,userPassW);
    char c;
    int pos = 0;
        printf("\n\n");
        printf("\tLOGIN SECURITY SYSTEM IN C USING TEXT FILES");
        printf("\n\n");
        printf("\tEnter User Name      : ");
        scanf("%s",&strID);
        printf("\n");
        printf("\tEnter Your Password  : ");
        do {
        c = getch();

        if( isprint(c) ) 
        {
            strPASSW[ pos++ ] = c;
            printf("%c", '*');
        }
        else if( c == 9 && pos )
        {
            strPASSW[pos--] = '\0';
            printf("%s", "\b \b");
        }
    } while( c != 13 );
        strcpy(strID,strcat(IDpref,strID));
        strcpy(strPASSW,strcat(PASSWpref,strPASSW));

        if (!strcmp(strID,userID)&&!strcmp(strPASSW,userPassW))
        {
            printf("\n\n");
            printf("\tCorrect Username And Password\n");
            printf("\n\n\tWelcome to the System\n\n"); 
        }
        else
        {
           printf("\n\n");
           printf("\tInvalid Username And Password. Try Again\n\n");
         }
     printf("\n\n");
     printf("\tEND OF PROGRAM");
     printf("\n\n");
     system("pause");
}


users.txt

user_id:admin
password:Jake123!@#



Sunday, January 6, 2019

12 LED's Running Lights in Arduino

In this article I would like to share with you a sample applications that I wrote using C in Arduino to perform 12 LED's Running Lights. The source code is very simple and easy to understand.

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

/* A simple program to sequentially turn on and turn off 12 LED's
   Author : Jake R. Pomperada, MAED-IT
   January 6, 2019  Sunday
   Bacolod City, Negros Occidental, Philippines
   jakerpomperada@gmail.com and jakerpomperada@yahoo.com
*/ 

int LED1 = 13;
int LED2 = 12;
int LED3 = 11;
int LED4 = 10;
int LED5 = 9;
int LED6 = 8;
int LED7 = 7;
int LED8 = 6;
int LED9 = 5;
int LED10 = 4;
int LED11 = 3;
int LED12 = 2;



void setup() {
   pinMode(LED1, OUTPUT);
   pinMode(LED2, OUTPUT);
   pinMode(LED3, OUTPUT);
   pinMode(LED4, OUTPUT);
   pinMode(LED5, OUTPUT);
   pinMode(LED6, OUTPUT);
   pinMode(LED7, OUTPUT);
   pinMode(LED8, OUTPUT);
   pinMode(LED9, OUTPUT);
   pinMode(LED10, OUTPUT);
   pinMode(LED11, OUTPUT);
   pinMode(LED12, OUTPUT);
}


void loop() {
  digitalWrite(LED1, HIGH);    // turn on LED1 
  delay(200);                  // wait for 400ms
  digitalWrite(LED2, HIGH);    // turn on LED2
  delay(200);                  // wait for 400ms       
  digitalWrite(LED3, HIGH);    // turn on LED3 
  delay(200);                  // wait for 400ms
  digitalWrite(LED4, HIGH);    // turn on LED4
  delay(200);                  // wait for 400ms
  digitalWrite(LED5, HIGH);    // turn on LED5
  delay(200);                  // wait for 400ms
  digitalWrite(LED6, HIGH);    // turn on LED6
  delay(200);                  // wait for 400ms
  digitalWrite(LED7, HIGH);    // turn on LED7
  delay(200);                  // wait for 400ms
  digitalWrite(LED8, HIGH);    // turn on LED8
  delay(200);                  // wait for 400ms
  digitalWrite(LED9, HIGH);    // turn on LED9
  delay(200);                  // wait for 400ms
  digitalWrite(LED10, HIGH);    // turn on LED10
  delay(200);                  // wait for 400ms
  digitalWrite(LED11, HIGH);    // turn on LED11
  delay(200);                  // wait for 400ms
  digitalWrite(LED12, HIGH);    // turn on LED12
  delay(200);                  // wait for 400ms
  digitalWrite(LED1, LOW);     // turn off LED1
  delay(200);                  // wait for 400ms
  digitalWrite(LED2, LOW);     // turn off LED2
  delay(200);                  // wait for 300ms
  digitalWrite(LED3, LOW);     // turn off LED3
  delay(200);                  // wait for 400ms
  digitalWrite(LED4, LOW);     // turn off LED4
  delay(200);                  // wait for 300ms
  digitalWrite(LED5, LOW);     // turn off LED5
  delay(200);                  // wait for 400ms
  digitalWrite(LED6, LOW);     // turn off LED6
  delay(200);                  // wait for 400ms
  digitalWrite(LED7, LOW);     // turn off LED7
  delay(200);                  // wait for 400ms
  digitalWrite(LED8, LOW);     // turn off LED8
  delay(200);                  // wait for 300ms
  digitalWrite(LED9, LOW);     // turn off LED9
  delay(200);                  // wait for 400ms
  digitalWrite(LED10, LOW);     // turn off LED10
  delay(200);                  // wait for 400ms
  digitalWrite(LED11, LOW);     // turn off LED11
  delay(200);                  // wait for 400ms
  digitalWrite(LED12, LOW);     // turn off LED8
  delay(200);                  // wait for 300ms before running program all over again
}


Addition and Difference in Delphi

Here is a simple program to perform addition and subtraction in Delphi. I used Delphi 7 Enterprise edition in writing 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




Program Listing

unit add_differece;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
   
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
var a,b : integer;

procedure TForm1.Button1Click(Sender: TObject);
begin
a:= strtoint(edit1.text);
b:= strtoint(edit2.text);
label6.caption := 'The sum of ' + inttostr(a) + ' and ' +inttostr(b) + ' is ' +inttostr(a+b) + '.';
label7.caption := 'The difference of ' + inttostr(a) + ' and ' +inttostr(b) + ' is ' +inttostr(a-b) + '.';
end;


procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.text := '';
edit2.text := '';
label6.caption :='';
label7.caption :='';
edit1.SetFocus;

end;


procedure TForm1.Button3Click(Sender: TObject);
begin
    if MessageDlg('Do you want to quit this program?', mtConfirmation, [mbYes, mbNO], 0) = mrYes then
begin
form1.Close;
end
else
begin
edit1.SetFocus;
end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin

end;

end.

Saturday, January 5, 2019

Swap Two Numbers Using Pointers 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

Problem 

Write a program that will ask the user to give two numbers and then 
the program will swap the arrangement of the two numbers and display
the result on the screen.

Solution

/* swap.c
   Author   : Jake Rodriguez Pomperada,BSCS,MAED-IT
   Date     : November 26, 2018  Monday  3:09 PM
   Location : Bacolod City, Negros Occidental
   Tool     : Dev C++ Version 5.11
   Website  : http://www.jakerpomperada.com
   Email    : jakerpomperada@jakerpomperada.com and jakerpomperada@gmail.com
*/
#include <stdio.h>

void swap(int *num1, int *num2);

int main()
{
    int num1=0, num2=0;
    printf("\n\n");
    printf("\tSwap Two Numbers");
    printf("\n\n");
    printf("\tEnter Two Numbers : ");
    scanf("%d%d", &num1, &num2);
    printf("\n\n");
    printf("\tBefore swapping in main");
    printf("\n\n");
    printf("\tValue of num1 = %d \n", num1);
    printf("\tValue of num2 = %d \n\n", num2);
    swap(&num1, &num2);
    printf("\n");
    printf("\tEnd of Program");
    printf("\n\n");
  
}

void swap(int * num1, int * num2)
{
    int temp;
    temp = *num1;
    *num1= *num2;
    *num2= temp;

    printf("\tAfter swapping in swap function ");
    printf("\n\n");
    printf("\tValue of num1 = %d. \n", *num1);
    printf("\tValue of num2 = %d. \n\n", *num2);

}

Largest of Three Numbers Using Pointers 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

Problem 

Write a program that will ask the user to give three numbers
and then the program will check which of the three numbers 
has the highest in terms of numerical value and display the
result on the screen.


Solution

#include<stdio.h>
int main()
{
  int x=0, y=0, z=0;
  int *a, *b, *c;
  
  printf("\n\n");
  printf("\tLargest of Three Numbers");
  printf("\n\n");
  printf("\tEnter Three Numbers : ");
  scanf("%d%d%d",&x, &y, &z);
  a = &x;
  b = &y;
  c = &z;
  if(*a > *b)
  {
    if(*a > *c)
    {
      printf("\n\n");
  printf("\t%d is larger than %d and %d.", *a, *b, *c);
    }
    else
    {
      printf("\n\n");
  printf("\t%d is larger than %d and %d.", *c, *a, *b);
    }
  } 
  else
  {
     if(*b > *c)
     {
        printf("\n\n");
printf("\t%d is larger than %d and %d.", *b, *a, *c);
     }
     else
     {
        printf("\n\n");
printf("\t%d is larger than %d and %d", *c, *a, *b);
     }
  }
printf("\n\n");
printf("\tEnd of Program");
printf("\n\n");


Area of the Circle Using Pointers in C

In this article, I would like to share with you a sample program that will ask the radius of the circle and compute its area and perimeters using pointers 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


Problem 

Write a program that will ask the user the radius of the circle
and then the program will compute it's area and perimeter of the circle
and display the result on the screen.

Program Listing

/* area_circle.c
   Author   : Jake Rodriguez Pomperada,BSCS,MAED-IT
   Date     : November 26, 2018  Monday  2:19 PM
   Location : Bacolod City, Negros Occidental
   Tool     : Dev C++ Version 5.11
   Website  : http://www.jakerpomperada.com
   Email    : jakerpomperada@jakerpomperada.com and jakerpomperada@gmail.com
*/

#include<stdio.h>

void solve_area( int r, float *a, float *p )
{
*a = 3.14 * r * r ;
*p = 2 * 3.14 * r ;
}

int main( )
{
int radius=0;
float area=0.00, perimeter=0.00 ;

printf("\n\n");
printf("\tArea of the Circle");
printf("\n\n");
printf ("\tEnter Radius of a Circle : " ) ;
scanf ( "%d", &radius ) ;

solve_area(radius, &area, &perimeter ) ;

printf("\n\n");
printf("\t===== DISPLAY REPORT =====");
printf("\n\n");
printf ( "\tThe Area = %.2f.", area ) ;
printf ( "\tThe Perimeter = %.2f.", perimeter ) ;
printf("\n\n");
printf("\tEnd of Program");
printf("\n\n");

}

Odd and Even Number Checker in Go

In this article, I share with you guys a simple if - else statement example how to check if the given number is an odd or even number from the user using Go 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



Sample Program Output

Program Listing

// odd_even.go

package main

import "fmt"

func main(){
    var num_value int32
    fmt.Print("\n")
    fmt.Print("\tOdd and Even Number Checker")
    fmt.Print("\n\n")
    fmt.Print("\tKindly give a number? ")
    fmt.Scanln(&num_value)
  if num_value % 2 ==0 {
       fmt.Print("\n")
       fmt.Print("\tThe given number ")
       fmt.Printf("%d",num_value)
       fmt.Print(" is an Even Number.")
    } else {
       fmt.Print("\n")
       fmt.Print("\tThe given number ")
       fmt.Printf("%d",num_value)
       fmt.Print(" is an Odd Number.")
    }
    fmt.Print("\n\n")
    fmt.Print("\tEnd of Program")
    fmt.Print("\n")
}




Leap Year Checker in Go

Happy New Year 2019 it has been a while since I wrote a code in my blog in this article I would like to share with you another sample program that I wrote using Go programming language to check if the given year is a leap year or not a leap year.

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


// leap_year.go

package main

import "fmt"

func main(){
    var year int32
    fmt.Print("\n")
    fmt.Print("\tLeap Year Checker")
    fmt.Print("\n\n")
    fmt.Print("\tGive a Year : ")
    fmt.Scanln(&year)
    if(((year % 4 == 0) && (year % 100 !=0)) || (year % 400==0)) {
       fmt.Print("\n")
       fmt.Print("\tThe given year ")
       fmt.Printf("%d",year)
       fmt.Print(" is a LEAP year.")
    } else {
       fmt.Print("\n")
       fmt.Print("\tThe given year ")
       fmt.Printf("%d",year)
       fmt.Print(" is NOT a LEAP year.")
    }
    fmt.Print("\n\n")
    fmt.Print("\tEnd of Program")
    fmt.Print("\n")
}