Friday, December 11, 2015

HTML form validation using Java-Script














<html>
<head>
<title>Form Validation using JavaScript</title>
</head>
<body>

<form name="form1" action="formvalidation.html" onsubmit="return validate()" method="post">
<input type="text" name="username">
<input type="submit" value="Submit">
</form>
<script type="text/javascript">
function validate() {
    var x = document.forms["form1"]["username"].value;
    if (x == null || x == "") {
        alert("Name must be filled out");
        return false;
}
}
</script>
</body>
</html>

Friday, November 27, 2015

Up-Date record in SQL Database using C#.net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Data;
using System.Data.SqlClient;

namespace WebApplication1
{
    public partial class WebForm2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            SqlConnection cnn = new SqlConnection(@"Data Source=localhost\SQLExpress;Initial Catalog=awais;Integrated Security=True;Integrated Security=True ");
            cnn.Open();
string query = "update logout set name ='"+TextBox3.Text+"' where name = '" + TextBox2.Text + "';";
            SqlCommand cmd = new SqlCommand(query, cnn);
            cmd.ExecuteNonQuery();

            Response.Write("update  is done!");

        }

   
    }
}


Friday, November 20, 2015

Retrieve / Collect data from SQL database using c#.Net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

 
        protected void Button2_Click(object sender, EventArgs e)
        {

            try
            {
                SqlConnection cnn = new SqlConnection(@"Data Source=localhost\SQLExpress;Initial Catalog=awais;Integrated Security=True;Integrated Security=True ");
                cnn.Open();
                SqlCommand command = new SqlCommand("SELECT name,password from logout;", cnn);


                SqlDataReader reader = command.ExecuteReader();

                if (reader.HasRows)
                {
                    Response.Write("<table border=\"3\">");
                    while (reader.Read())
                    {
                        Response.Write("<tr><th width=\"40\">"+ reader.GetString(0) +"</th><th>"+ reader.GetString(1)+"</th></tr>");
                    } Response.Write("</table>");
                }
                else
                {
                    Response.Write("No rows found.");
                }
                reader.Close();
            }
            catch (SystemException ex) { Response.Write(ex); }
           
        }
    }
}


Saturday, October 24, 2015

Measurement Scales Converter in vb.net


Vb.net Code:-

Public Class WebForm1
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim a As Single
        Dim b As Single

        Dim c As Single
        Dim inch As Single
        Dim yard As Single
        Dim meter As Single
        Dim fathom As Single
        Dim rod As Single
        Dim furlong As Single
        Dim kilometer As Single
        Dim mile As Single
        Dim foot As Single
        yard = 3
        meter = 3.28155
        fathom = 6
        rod = 16.5
        furlong = 660
        kilometer = 32815
        mile = 5280
        If Val(TextBox1.Text) = 1 Then
            a = inch
        End If
        If TextBox1.Text = 2 Then
            a = yard
        End If
        If TextBox1.Text = 3 Then
            a = meter
        End If
        If TextBox1.Text = 4 Then
            a = fathom
        End If
        If TextBox1.Text = 5 Then
            a = rod
        End If
        If TextBox1.Text = 6 Then
            a = furlong
        End If
        If TextBox1.Text = 7 Then
            a = kilometer
        End If
        If TextBox1.Text = 8 Then
            a = mile
        End If
        If Val(TextBox2.Text) = 1 Then
            b = inch
        End If
        If TextBox2.Text = 2 Then
            b = yard
        End If
        If TextBox2.Text = 3 Then
            b = meter
        End If
        If TextBox2.Text = 4 Then
            b = fathom
        End If
        If TextBox2.Text = 5 Then
            b = rod
        End If
        If TextBox2.Text = 6 Then
            b = furlong
        End If
        If TextBox2.Text = 7 Then
            b = kilometer
        End If
        If TextBox2.Text = 8 Then
            b = mile
        End If
        c = Val(TextBox3.Text) * a

        Dim ans As Integer

        ans = c / b
        TextBox4.Text = ans




    End Sub
End Class




Form:-



HTML CODE:-

Monday, October 5, 2015

Polymorphism in C# : Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication5
{
    class Shape
    {
        protected int width, height;
        public Shape()
        {
        }
        public virtual void area(int width, int height)
        {
            Console.WriteLine("Parent class area :");
            Console.WriteLine("Shape has no spasific area ");
        }
    }

    class Rectangle : Shape
    {
        public Rectangle() : base()
        {

        }
        public override void area(int width, int height)
        {
            Console.WriteLine("Rectangle class area :");
            Console.WriteLine(width * height);
        }
    }
   
    class Triangle : Shape
    {
        public Triangle() : base()
        {

        }
        public new void area(int width,int height)
        {
            Console.WriteLine("Triangle class area :");
            Console.WriteLine(width * height / 2);
        }
    }
   
    class Tester
    {

        static void Main(string[] args)
        {
            Shape s = new Shape();
            Rectangle r = new Rectangle();
            Triangle t = new Triangle();
            s.area(0,0);
            r.area(10,7);
            t.area(10,5);

            Shape s1 = new Rectangle();
            s1.area(10, 15);

            Shape s2 = new Triangle();
            s2.area(22, 76);

            Console.ReadKey();
        }
    }
}

Thursday, September 24, 2015

Multilevel Inheritance and Function Overriding in Java

package oop;
public class Oop {

    public static class A{
        void func(){
            System.out.println("Function of A");
        }
    void func1(){
            System.out.println("Function of A");
        }
    }
    public static class B extends A{
        void func(){
            System.out.println("Function of B");
        } 
    void func1(){
        super.func1();
            System.out.println("Function of B");
        }    
    }
    public static class C extends B{
        void func(){
            System.out.println("Function of C");
        }        
    void  func1(){
        super.func1();
            System.out.println("Function of C");
        }
    }
    public static void main(String[] args) {
     
     
        C obj4=new C();
        obj4.func();
        obj4.func1();
    }
    }


Sunday, September 13, 2015

Interface /Abstract Classes in C++

An interface describes the behavior or capabilities of a C++ class without committing to a particular implementation of that class.
The C++ interfaces are implemented using abstract classes and these abstract classes should not be confused with data abstraction which is a concept of keeping implementation details separate from associated data.
A class is made abstract by declaring at least one of its functions as pure virtual function. A pure virtual function is specified by placing "= 0" in its declaration as follows:



#include <iostream.h>

class Shape

{

public:

// pure virtual function providing interface framework.

virtual int getArea() = 0;

void setWidth(int w)

{

width = w;

}

void setHeight(int h)

{

height = h;

}

protected:

int width;

int height;

};



class Rectangle: public Shape

{

public:

int getArea()

{

return (width * height);

}

};

class Triangle: public Shape

{

public:

int getArea()

{

return (width * height)/2;

}

};



int main(void){

Rectangle Rect;

Triangle Tri;

Rect.setWidth(5);

Rect.setHeight(7);

cout << "Total Rectangle area: " << Rect.getArea() << endl;

Tri.setWidth(5);

Tri.setHeight(7);

cout << "Total Triangle area: " << Tri.getArea() << endl;

return 0;

}

Interfaces in C#

An interface is defined as a syntactical contract that all the classes inheriting the interface should follow. The interface defines the 'what'part of the syntactical contract and the deriving classes define the 'how'part of the syntactical contract.
Interfaces define properties, methods, and events, which are the members of the interface. Interfaces contain only the declaration of the members. It is the responsibility of the deriving class to define the members. It often helps in providing a standard structure that the deriving classes would follow.
Abstract classes to some extent serve the same purpose, however, they are mostly used when only few methods are to be declared by the base class and the deriving class implements the functionalities.



using System;
namespace ArrayApplication
{
    public interface person{
         void name(string n);
         void age(int a );
         void clas(int c);
    }
   
    public class usman : person{
    public  void name(string n){
        Console.WriteLine("Usman name= "+n);
    }
    public void age(int a){
        Console.WriteLine("Usman age= "+a);
    }
    public void clas(int c){
        Console.WriteLine("Usman class= "+c);
    }
    }
   
    public class usama : person{
    public void name(string n){
        Console.WriteLine("Usman name= "+n);
    }
    public void age(int a){
        Console.WriteLine("Usman class= "+a);
    }
    public void clas(int c){
        Console.WriteLine("Usman class= "+c);
    }  
    }
   
   public class test
   {
       public static void Main(String[] args){
           usama obj=new usama();
           obj.name("Usama hussain");
           obj.age(20);
           obj.clas(10);
         
           usman obj1=new usman();
           obj1.name("Usman Siddique");
           obj1.age(21);
           obj1.clas(09);
       }
   }
}

=========================================
using System;
namespace ArrayApplication
{
    public interface abc{
         void fun();
              }

   public class MyArray : abc
   {
                                                         public void fun(){
                                                        Console.WriteLine("this is defination of interface fun");
                                                       }
                                                       static void Main(string[] args){
                                                       MyArray obj=new MyArray();
                                                      obj.fun();
                                                      }    }    }
       
   

Inheritance in C#

using System;
namespace ArrayApplication
{
    class abc{
        public void fun(){
            Console.WriteLine("This is A function of base class abc");
        }
    }
   class MyArray : abc  
   {
       static void Main(string[] args)
      {
         MyArray obj=new MyArray();
         obj.fun();
      }
   }
}

Argument / Parameter passing in C# Functions

using System;
namespace ArrayApplication
{
   class MyArray
   {
       public MyArray(){
           Console.WriteLine("Construtor Invoke");
       }
       public void myfun(int a){
           Console.WriteLine("User Pass the value = "+a);
       }
      static void Main(string[] args)
      {
         MyArray obj=new MyArray();
         obj.myfun(20);
       
      }
   }
}

Functions in C#

using System;
namespace ArrayApplication
{
   class MyArray
   {
       public MyArray(){
           Console.WriteLine("Construtor Invoke");
       }
       public void myfun(){
           Console.WriteLine("Its a funtion under My Array class");
       }
      static void Main(string[] args)
      {
         MyArray obj=new MyArray();
         obj.myfun();
       
      }
   }
}

Object Creation and Constructor in C#

using System;
namespace ArrayApplication
{
   class MyArray
   {
       public MyArray(){
           Console.WriteLine("Construtor Invoke");
       }
      static void Main(string[] args)
      {
         MyArray obj=new MyArray();
       
      }
   }
}

Create a table in C#

using System;
namespace ArrayApplication
{
   class MyArray
   {
      static void Main(string[] args)
      {
         int no,i;
         no=5;
         for(i=1;i<=10;i++){
             Console.WriteLine(no+" * "+i+" = "+no*i);
         }
      }
   }
}

Hello World in C#

using System;
namespace ArrayApplication
{
   class MyArray
   {
      static void Main(string[] args)
      {
         Console.WriteLine("Helo World...Its my First C# Program");
      }
   }
}


Saturday, September 12, 2015

Constructor and Object in Java

Different Types Of Constructor in Java ... Default Constructor,Pramiterized Constructor ,,Over-loaded Constructor:-

package oop;
public class Oop {

    public int ID;
    public String name;
    public char bloodgroup;
   
    Oop(){
        System.out.println("This is the Default Constructor");
    }
    Oop(int a){
        System.out.println("This is a prametrized Constructor No= "+a);
    }
    Oop(String a){
        System.out.println("This is an other Constructor name= "+a);
    }
   
    public static void main(String[] args) {
        Oop obj1=new Oop();
        Oop obj2=new Oop(2015);
        Oop obj3=new Oop("3rd Constructor");
       
        obj1.ID=34;
        obj1.name="usman";
        obj1.bloodgroup='a';
               
    }
}

=================================
package usman1;
public class Usman1 {
    int age;
    String name;
    public Usman1(int a,String b){
age=a;
name=b;
System.out.println("Name= "+name+" age= "+age);
    }
    public static void main(String[] args) {
     Usman1 obj=new Usman1(20,"Usman Siddique");
    }  
    }

Tuesday, September 8, 2015

5th Semester E-Books BSE-5

DLD (Digital Logic and Computer Design)  

by Morris Mano 4th edition .pdf


Click Here:-



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

OPERATING SYSTEM CONCEPTS 9th Edition .pdf

ABRAHAM SILBERSCHATZ
 Yale University
PETER BAER GALVIN
 Pluribus Networks 
GREG GAGNE 
Westminster College

Click Here:-

Friday, August 7, 2015

Change Your Mouse Cursor Into Pakistan Flag


Salam To All & Happy Independence Day !! :)

To day I am Gonna Tell You That How To Change Your Cursor Into Pakistan Flag !!
It's Very Easy Follow These Steps Respectively
Fist Download Pakistan Cursor Click Here To Download
(It's Not Too Large It's Just 21Kbs)
1. Save Attached File in your PC 
2. Go to Start menu + Settings + Control Panel 
3. Double click on Mouse Icon 
4. Go in Pointer
5. Click on Browse menu and select saved File (PAKISTAN.ani)
6. Click Apply and Ok.


We Have Finished Now.. Chek Your Cursor Now It has changed into Pakistan Flag !!


Pakistan Zindabad !!



" Prewiew Is Given Below !! "



Thursday, August 6, 2015

Pakistan Flag using C++ : For Loop

‪#‎include‬ <iostream.h>
#include <conio.h>
void main(){
clrscr();
int x=20,z=x-14;
for(int i=z-z;i<=x+x;i++){ cout<<"*";}cout<<endl;
for(int j=z-z;j<=x;j++){cout<<"ÛÛÛÛÛÛÛÛÛÛ\t\t\t\t*\n";}
for(int k=z-z;k<=x+x;k++){ cout<<"*";}
gotoxy(x,z++); {cout<<" _**";}
gotoxy(x,z++); {cout<<" *";}
gotoxy(x,z++); {cout<<" * * ";}
gotoxy(x,z++); {cout<<" ** ** **";}
gotoxy(x,z++);{cout<<" *** *** ";}
gotoxy(x,z++);{cout<<" ** * *";}
gotoxy(x,z++);{cout<<" * ";}
gotoxy(x,z++);{cout<<" *";}
gotoxy(x,z++);{cout<<" ~**";}
gotoxy(1,24);{for(int c=1;c<=21;c++)cout<<"**\n";}
getch();
}

Sunday, June 28, 2015

Calculator using PHP and Css 3 ,html 5

Calculator Using PHP...

<title>Calculator</title>
<style>
span{
background-color: lightgreen;
border: 2px solid black;
textcolor: red;
}
div input{
    background-color: lightgrey;
    width: 320px;
    padding: 5px;
    border: 1px solid navy;
    margin: 25px;
}
div button{
    background-color: #FFFFF0;
    width: 360px;
    height: 40px;
    padding: 5px;
    border: 2px solid green;
 
}
div td{
    background-color:#FFEBFF;
    width: 200px;
    height: 10px;
    padding: 5px;
    border: 2px solid navy;
    }
div th{
    background-color: #FFD6D6;
    width: 200px;
    height: 10px;
    padding: 5px;
    border: 2px solid navy;
 
}
 p{
    background-color: #FFF5FF;
    width: 420px;
    height: 25px;
    padding: 5px;
    border: 3px solid black;

}
</style>


<form action=" " method="POST">
<div><table border=2"><tr><th color="red" width="59">
Value 1:<br><input type="text" name="a" ></th><th>
Value 2:<br><input type="text" name="b" ></th></tr><tr><td>
<input type="radio" name="s" value="+">Additon<br></td><td>
<input type="radio" name="s" value="-">Subtraction<br></td></tr><tr><td>
<input type="radio" name="s" value="*">Multiplication<br></td><td>
<input type="radio" name="s" value="/">Division<br></td></tr><tr><td>
<input type="radio" name="s" value="sin">Sin<br></td><td>
<input type="radio" name="s" value="cos">Cos<br></td></tr><tr><td>
<input type="radio" name="s" value="tan">Tan<br></td><td>
<input type="radio" name="s" value="decbin">Decimal to Binary<br></td></tr><tr><td>
<input type="radio" name="s" value="bindec">Binary to Decimal<br></td><td>
<input type="radio" name="s" value="dechex">Decimal to Hexa<br></td></tr><tr><td>
<input type="radio" name="s" value="hexdec">Hexa to Decimal<br></td><td>

</div>
<button value="Submit" name="submit" type="Submit">Submit</button></td></tr>
</form>

<tr>
<?php
$ans=0;
$a=$_POST['a'];
$b=$_POST['b'];
$q=$_POST['s'];
switch($q)
{
case "+":
$ans=$a+$b;
echo "Sum= ".$ans;
break;
case "-":
$sub=$a-$b;
echo "Sub= ".$sub;
break;
case "*":
$mul=$a*$b;
echo "Mul= ".$mul;
break;
case "/":
$div=$a / $b;
echo "DIV= ".$div;
break;
case cos:
 $ans = cos($a);
  break;
  case sin:
 $ans = sin($a);
  break;
  case tan:
 $ans = tan($a);
  break;
  case decbin:
 $ans = decbin($a);
  break;
  case bindec:
 $ans = bindec($a);
  break;
  case dechex:
 $ans = dechex($a);
  break;
  case hexdec:
 $ans = hexdec($a);
  break;
  case deg2rad:
 $and = deg2rad($a);
  break;
  case rad2deg:
 $ans = rad2deg($a);
  break;
}
echo "<p><i><b> Answer =<b><i> ".$ans."</p>";
//echo "<input type=/"text/" value='".$ans."'>";


?></tr></table>

<center><span>Copyright @ Programming SeekerzzZ </span></center>




Value 1:
Value 2:
AdditonSubtraction
MultiplicationDivision
SinCos
TanDecimal to Binary
Binary to DecimalDecimal to Hexa
Hexa to Decimal
Answer = ".$ans.""; ?>
Copyright @ Programming SeekerzzZ

Saturday, June 27, 2015

Thursday, June 25, 2015

Graph Adjacency Matrix using 2D-Array

#include <iostream.h>
#include<conio.h>

void  main( )
 {
 int i, j ,siz;
 clrscr();
 int G[100][100];

cout<<" Enter the size of sequre Metrix  \n";
cout<<" Enter Rows siz :";
 cin>>i;
 cout<<" \n Enter Colums siz : "   ;
 cin>>j;
 siz=j;

 for(i=0 ; i < siz  ; i++)
 for(j=0 ; j< siz ; j++)
 {
 G[i][j]=0;
 }
 int a;
 cout<<" \n Enter the No of Edges: ";
 cin>>a;
 cout<<" \n Enter the exact location where  do you want  make edge  : "<<endl;
 for (int j1=1 ; j1 <= a ; j1++)
 {
 cout<<" Enter Row Number :";
 cin>>i;
 cout<<" Enter colum Number : ";
 cin>>j;
 G[i][j]=1;
 }
 cout<< " Adjancy Matrix ";
 for(i=0; i < siz; i++)
 {
 cout<< " \n ";
 for( j=0; j < siz ; j++)
 {
 cout<<"    "<< G[i][j];
 }
 cout<< " \n ";
 }
getch();
}




Graph Adjacency List using Link list

#include<iostream.h>
#include<conio.h>

struct Adj_list
{

int dest;
struct Adj_list *next;

};
struct Adjlist
{
struct Adj_list *head;

};


class Graph
{
int v;
int i;
public:
struct Adjlist *array;

Graph(int v)
{
this->v=v;
array=new Adjlist[v];
array[i].head=NULL;
}

Adj_list *newAdj_list(int dest)
{

Adj_list *newnode =new Adj_list;
newnode->dest=dest;
newnode->next=NULL;
return newnode;
}



void addedge(int src,int dest)
{

Adj_list *newnode=newAdj_list(dest);

newnode->next=array[src].head;
array[src].head=newnode;
newnode=newAdj_list(src);
newnode->next=array[dest].head;
array[dest].head=newnode;
}

void display()
{

int i;
for(i=0; i< v; i++)
{
Adj_list *pcrawl=array[i].head;
cout<<" \n Adjancy List of vertex  "<<i<<" head";

while(pcrawl)
{
cout<<" -> "<<pcrawl->dest;
pcrawl=pcrawl->next;

}
cout<<endl;
}



}
};
void main()
{
clrscr();
Graph obj(5);
obj.addedge(0,1);
obj.addedge(0,4);
obj.addedge(1,2);
obj.addedge(1,3);
obj.addedge(1,4);
obj.addedge(2,3);
obj.addedge(3,4);

obj.display();
getch();
}

Saturday, June 13, 2015

Scan string using SCASB : Assembly code

include irvine32.inc

.data
source byte "my name is usman",0

msg1 byte "String to b compare : ",0


msg3 byte "Latter is Found : ",0
msg4 byte "Latter Not Found : ",0

.code
Main proc
call clrscr
call crlf
mov edx,offset msg1
call writestring
call crlf

call crlf
mov edx,offset source
call writestring
call crlf


;---------------------------

mov edi,offset source
mov al,'g'
mov ecx,lengthof source
cld
repne scasb
je L1
jne L2
;----------------------

L1:
call crlf
mov edx,offset msg3
call writestring
call crlf
jmp e

L2:
call crlf
mov edx,offset msg4
call writestring
call crlf
jmp e


e:
exit
main endp
end main

Compare string using CMPSB : Assembly Code

include irvine32.inc

.data
source byte "i my name is usman",0
dest   byte "i am not a khan....",0

msg1 byte "1st String: ",0
msg2 byte "2nd string: ",0

msg3 byte "String name Dest is Large : ",0
msg4 byte "String name Dest is Small : ",0
msg5 byte "String :both sorce & Dest are Equal : ",0

.code
Main proc
call clrscr
call crlf
mov edx,offset msg1
call writestring
call crlf

call crlf
mov edx,offset source
call writestring
call crlf

call crlf
mov edx,offset msg2
call writestring
call crlf

call crlf
mov edx,offset dest
call writestring
call crlf

mov esi,offset source
mov edi,offset dest
mov ecx,lengthof source
repe cmpsb
ja L1
jb L2
jmp L3

L1:
call crlf
mov edx,offset msg3
call writestring
call crlf
jmp e

L2:
call crlf
mov edx,offset msg4
call writestring
call crlf
jmp e

L3:
call crlf
mov edx,offset msg5
call writestring
call crlf
jmp e

e:
exit
main endp
end main


Copy using Movsb : Assembly Code

include irvine32.inc

.data
source byte "    my name is usman",0
dest   byte "    I am not a khan.",0
msg3 byte "After Copy: Copy source in dest String:  ",0
msg1 byte "String Named Source: ",0
msg2 byte "String Named Dest: ",0

.code
Main proc
call clrscr
call crlf
mov edx,offset msg1
call writestring
call crlf

call crlf
mov edx,offset source
call writestring
call crlf

call crlf
mov edx,offset msg2
call writestring
call crlf

call crlf
mov edx,offset dest
call writestring
call crlf
;-------------------------------
cld
mov esi,offset source
mov edi,offset dest
mov ecx,lengthof dest
rep movsb
;--------------------------------
call crlf
call crlf
mov edx,offset msg3
call writestring
call crlf

call crlf
mov edx,offset source
call writestring
call crlf

call crlf
mov edx,offset msg2
call writestring
call crlf

call crlf
mov edx,offset dest
call writestring
call crlf

exit
main endp
end main

Push & Pop in Assembly :: Stack

include irvine32.inc

.data

msg3 byte "Push character one by one in stack and moves ESP(32-bit-stack-pointer-register) downward:",0
msg byte "              Push: ",0
msg4 byte "Pop character one by one from stack and moves ESP(32-bit-stack-pointer-register) upward:",0
msg1 byte "              Pop: ",0
arr byte "usman siddique",0
asiz = ($-arr)-1
msg2 byte "---------------------------------------------------------------",0
msg5 byte "After perfoming the pop operation the name will print in reverse order.Now think about it, why it happens",0
msg6 byte "                      Name:  ",0
msg7 byte ".......................~~THE END~~.............................",0

.code
main proc
call clrscr
mov edx,offset msg3
call writestring
call crlf
mov ecx,asiz
mov esi,0

L1:
mov edx,offset msg
call writestring
movzx eax,arr[esi]
push eax ;PUSH:  In runtime stack ESP moves in downward direction instead of moving upward
                            ;but it does not matter what the  direction is,because stack follows LIFO structure in both(downward/upward) cases.
call writechar
call delay
call delay
call delay
call delay
call crlf
inc esi
loop L1

call crlf
mov edx,offset msg2
call writestring
call crlf
mov edx,offset msg4
call writestring
call crlf
mov ecx,asiz
mov esi,0
L2:
mov edx,offset msg1
call writestring
pop eax        ;POP:   In runtime stack ESP moves in upward direction instead of moving downward
                            ;but it does not matter what the direction is,because stack follows LIFO structure in both(downward/upward) cases.
mov arr[esi],al
call delay
call delay
call delay
call delay

call writechar
call crlf
inc esi
loop L2
call crlf
mov edx,offset msg5
call writestring
call crlf
call crlf
call crlf
call waitmsg ;show a msg: Press [Enter] to continue..
mov edx,offset msg6
call writestring
mov edx,offset arr
call writestring
call crlf
call crlf
call crlf
mov edx,offset msg7
call writestring
call crlf
call crlf
exit
main endp
end main

Str_Trim Function in Assembly

include irvine32.inc

.data
source byte "my name is usman and i am not A KHAN",0
msg   byte "After Invoking Str_trim function: ",0
msg1 byte "Lenght of source = ",0

.code
Main proc
call clrscr
call crlf
mov edx,offset msg1
call writestring
call crlf

call crlf
mov edx,offset source
call writestring
call crlf


call crlf
mov edx,offset msg
call writestring
call crlf


invoke str_trim , addr source , 'N'


call crlf
mov edx,offset source
call writestring

call crlf

exit
main endp
end main


Str_Length Function in Assembly

include irvine32.inc

.data
source byte "my name is usman and i am not A KHAN",0
msg   byte "After Iviking Str_Length function: ",0
msg1 byte "Lenght of source = ",0

.code
Main proc
call clrscr
call crlf
mov edx,offset msg1
call writestring
call crlf

call crlf
mov edx,offset source
call writestring
call crlf


call crlf
mov edx,offset msg
call writestring
call crlf


invoke str_length , addr source


call crlf
mov edx,offset msg1
call writestring
call writedec
call crlf

exit
main endp
end main

U_Case Function in Assembly

include irvine32.inc

.data
source byte "my name is usman and i am not A KHAN",0
msg   byte "After Iviking U-Case function: ",0
msg1 byte "String Source is = ",0

.code
Main proc
call clrscr
call crlf
mov edx,offset msg1
call writestring
call crlf

call crlf
mov edx,offset source
call writestring
call crlf


call crlf
mov edx,offset msg
call writestring
call crlf


invoke str_ucase , addr source


call crlf
mov edx,offset source
call writestring
call crlf

exit
main endp
end main

Str_Compare Function in Assembly

include irvine32.inc

.data
source byte "i  my name is usman",0
dest   byte "i am not a khan....",0

msg1 byte "1st String: ",0
msg2 byte "2nd string: ",0

msg3 byte "String name Dest is Large : ",0
msg4 byte "String name Dest is Small : ",0
msg5 byte "String :both sorce & Dest are Equal : ",0

.code
Main proc
call clrscr
call crlf
mov edx,offset msg1
call writestring
call crlf

call crlf
mov edx,offset source
call writestring
call crlf

call crlf
mov edx,offset msg2
call writestring
call crlf

call crlf
mov edx,offset dest
call writestring
call crlf

invoke str_compare , addr source ,addr dest
ja L1
jb L2
jmp L3

L1:
call crlf
mov edx,offset msg3
call writestring
call crlf
jmp e

L2:
call crlf
mov edx,offset msg4
call writestring
call crlf
jmp e

L3:
call crlf
mov edx,offset msg5
call writestring
call crlf
jmp e

e:
exit
main endp
end main

Str_Copy Function in Assembly

include irvine32.inc

.data
source byte "my name is usman",0
dest   byte "i am not a khan.",0

msg1 byte "1st String: ",0
msg2 byte "2nd string: ",0
msg3 byte "after Copy :: copy source string into dest : ",0

.code
Main proc
call clrscr
call crlf
mov edx,offset msg1
call writestring
call crlf

call crlf
mov edx,offset source
call writestring
call crlf

call crlf
mov edx,offset msg2
call writestring
call crlf

call crlf
mov edx,offset dest
call writestring
call crlf

call crlf
mov edx,offset msg3
call writestring
call crlf

invoke str_copy , addr source ,addr dest
;copy source string into dest

call crlf
mov edx,offset dest
call writestring
call crlf

exit
main endp
end main


Thursday, June 11, 2015

DFS tree in C++

#include<iostream.h>
#include<conio.h>
int cost[10][10],i,j,k,n;
int stack[10],top,v,visit[10],visited[10];
void main()
{
clrscr();
int m;
cout <<"Enter no of vertices\Nodes: ";
cin >> n;
cout <<"\nEnter no of Edges: ";
cin >> m;
cout <<"\n\tEnter All EDGES Source & Distination\n";
for(k=1;k<=m;k++)
{
cout<<"\nEnter Source: ";
cin >>i;
cout<<"\nEnter Distination: ";
cin>>j;
cost[i][j]=1;
cout<<"\n-----------------------\n";
}
cout <<"\nEnter initial vertex: ";
cin >>v;
cout <<"\nORDER OF VISITED VERTICES:\n";
cout <<v<<" ";
visited[v]=1;
k=1;
while(k<n)
{
for(j=n;j>=1;j--)
if(cost[v][j]!=0 && visited[j]!=1 && visit[j]!=1)
{
visit[j]=1;
stack[top]=j;
top++;
}
v=stack[--top];
cout<<v << " ";
k++;
visit[v]=0;
visited[v]=1;
}
getch();
}

Breadth First Search (BFS) in Graphs Algorithm Code in C++

#include<iostream.h>
#include<conio.h>
int cost[10][10],i,j,k,n;
int que[10],front,rare,v,visit[10],visited[10];
void main()
{
clrscr();
int m;
cout <<"Enter no of vertices\ Nodes: ";
cin >> n;
cout <<"\nEnter no of Edges: ";
cin >> m;
cout <<"\n\tEnter All EDGES by source & destination\n";
for(k=1;k<=m;k++)
{
cout<<"\nEnter Source: ";
cin >>i;
cout<<"\nEnter Destination: ";
cin>>j;
cost[i][j]=1;
cout<<"\n-----------------------\n";
}
cout <<"\nEnter initial vertex: ";
cin >>v;
cout <<"Visitied vertices:\n";
cout << v<<" ";
visited[v]=1;
k=1;
while(k<n)
{
for(j=1;j<=n;j++)
if(cost[v][j]!=0 && visited[j]!=1 && visit[j]!=1)
{
visit[j]=1;
que[rare++]=j;
}
v=que[front++];
cout<<v << " ";
k++;
visit[v]=0;
visited[v]=1;
}
getch();
}

Tuesday, June 9, 2015

HAng MaN Game in C++

#include<iostream.h>
#include<conio.h>
#include<string.h>
#include <stdlib.h>
int a;
void main()
{

char ch[50],new1[50],word[50];
cout<<"              ------------------------------------------------"<<endl;
cout<<"                        Welcome To the HAng MaN Game "<<endl;
cout<<"              ------------------------------------------------"<<endl<<endl;
cout<<"                         |(((( Player OnE )))) | "<<endl<<endl ;
cout<<" HOW many character U Want to ENter == ";
cin>>a;
int g=11;

 ch[a],new1[a],word[a];
cout<<" \n \n";
cout<<"\n \n PLZ Insert Yr COmplete Words ==== ";

for(int b1=0;b1<a;b1++)
  { new1[b1]='_';

    cin>>ch[b1];
  }
f:
system("cls");

cout<<"                         ------------------------- \n ";
cout<<"                              PLayer Two  \n";
cout<<"                         ------------------------- \n\n ";
cout<<"                      ****************************** \n";
cout<<"                             GUess The characters  \n ";
cout<<"                      ****************************** \n \n \n";


cout<<"YOu have "<<g<<" tries Other wise your man will Hang \n\n";

cout<<"your Enter Charater Are === ";
for(int t=0;t<a;t++)
{
cout <<new1[t];
}
cout<<"\n";
if(g==10)
{
cout<<"                                                     /       "<<endl;
}
if(g==9)
{
cout<<"                                                     /       "<<endl;
cout<<"                                                    /        "<<endl;
}
if(g==8)
{
cout<<"                                                    __       "<<endl;
cout<<"                                              *-*-* /        "<<endl;
cout<<"                                                   /         "<<endl;
}
if(g==7)
{

cout<<"                                                    __        "<<endl;
cout<<"                                              *-*-* /         "<<endl;
cout<<"                                              ('_')/          "<<endl;
}
if(g==6)
{
cout<<"                                                    __        "<<endl;
cout<<"                                              *-*-* /         "<<endl;
cout<<"                                              ('_')/          "<<endl;
cout<<"                                                |             "<<endl;
}
if(g==5)
{

cout<<"                                                    __        "<<endl;
cout<<"                                              *-*-* /         "<<endl;
cout<<"                                              ('_')/          "<<endl;
cout<<"                                                |             "<<endl;
cout<<"                                                |             "<<endl;
}

if(g==4)
{
cout<<"                                                    __        "<<endl;
cout<<"                                              *-*-* /         "<<endl;
cout<<"                                              ('_')/          "<<endl;
cout<<"                                                |             "<<endl;
cout<<"                                               /|             "<<endl;


}
if(g==3)
{
cout<<"                                                    __        "<<endl;
cout<<"                                              *-*-* /         "<<endl;
cout<<"                                              ('_')/          "<<endl;
cout<<"                                                |             "<<endl;
cout<<"                                               /|\\           "<<endl;
}


if(g==2)
{
cout<<"                                                    __        "<<endl;
cout<<"                                              *-*-* /         "<<endl;
cout<<"                                              ('_')/          "<<endl;
cout<<"                                                |             "<<endl;
cout<<"                                               /|\\           "<<endl;
cout<<"                                                |             "<<endl;
}
if(g==1)
{
cout<<"                                                    __        "<<endl;
cout<<"                                              *-*-* /         "<<endl;
cout<<"                                              ('_')/          "<<endl;
cout<<"                                                |             "<<endl;
cout<<"                                               /|\\           "<<endl;
cout<<"                                                |             "<<endl;
cout<<"                                               / \\           "<<endl;

}
cout<<"\n\n";
cout<<" Enter charater ====" ;

int c,m=-1,l=0;
 for(int b=1;b<=a+a;b++)
 {
    cin>>word[b];
    for( c=0;c<a;c++)
      {
if(word[b]==ch[c])
{

new1[c]=word[b];

m=c;
}

       }
 if(m==-1)
g--;
 break;
 }


 for(int p=0;p<a;p++)
if(ch[p]==new1[p])
{
l++;
}
else
{ if(g>0)
 goto f;
system("cls");
cout<<"\n\n";
cout<<"                             -------------------         \n ";
cout<<"                             (((  You LOst ))))           \n ";
cout<<"                            -------------------         \n\n\n ";
cout<<"                                          __        "<<endl;
cout<<"                                    *-*-* /         "<<endl;
cout<<"                                    ('_')/          "<<endl;
cout<<"                                      |             "<<endl;
cout<<"                                     /|\\           "<<endl;
cout<<"                                      |             "<<endl;
cout<<"                                     / \\           "<<endl;

cout<<"Right Answer is ====== ";
for(int t=0;t<a;t++)
{
cout <<ch[t];
}
cout<<"\n\n\n\n\n";
}

if(l==a)
{
system("cls");

for(int t=0;t<a;t++)
{
cout <<new1[t];
}
cout<<"\n\n\n\n\n\n";
cout<<"                             -------------------         \n ";
cout<<"                              (((  You Won ))))           \n ";
cout<<"                            -------------------         \n\n\n\n\n ";

}
 getche();
}