Mar 30, 2011

Change the Location of Special Folders

This tweak allows changing the location of special folders on the system. Any of the folders listed in the registry key may be moved.

[Start] [Run] [Regedit]

Go to : HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\UserShell Folders

Modify/Create String value of Data type REG_SZ Named [Various Folder Names]

Data Type: REG_SZ [String Value] // Value Name: Consult RegEdit for Folder Names

Value Data: [Move the folder to the new desired location using explorer, and then edit the matching folder in RegEdit to reflect the new folder location]

Exit Registry and Reboot

Program to implement all the operations on stack

#include<stdio.h>
#include<conio.h>
int stack[100],tos=-1;
void main()
{
    int ch;
    do
    {
        clrscr();
        printf("\n Stack ");
        printf("\n 1. PUSH");
        printf("\n 2. POP");
        printf("\n 3. PEEP");
        printf("\n 4. DISPLAY");
        printf("\n 5. Exit");
        printf("\n Enter your choice :");
        scanf("%d",&ch);
        switch(ch)
        {
            case 1:
                push();
                getch();
                continue;
            case 2:
                pop();
                getch();
                continue;
            case 3:
                peep();
                getch();
                continue;
            case 4:
                display();
                getch();
                continue;
        }
    }while(ch!=5);
}
push()
{
    int x;
    if(tos==99)
    {
        printf("\n Stack is Full");
        return;
    }
    printf("\n Enter value : ");
    scanf("%d",&x);
    stack[++tos] = x;
    return;
}
pop()
{
    int x;
    if(tos==-1)
    {
        printf("\n Stack is Empty");
        return;
    }
    x = stack[tos--];
    printf("\n Element popped ... %d",x);
    return;
}
peep()
{
    if(tos==-1)
    {
        printf("\n Stack is Empty");
        return;
    }
    printf("\n Element on top of the stack : %d",stack[tos]);
    return;
}
display()
{
    int x;
    if(tos==-1)
    {
        printf("\n Stack is Empty");
        return;
    }
    for(x=tos;x>=0;x--)
        printf("\n Element on stack[%d] is  : %d",x+1,stack[x]);
    return;
}


C Program For Bubble Short Method

#include<stdio.h>
#include<conio.h>
void main()
{
    int *p,i,n;
    clrscr();
    printf("\n How many elements to sort :");
    scanf("%d",&n);

    p=(int *) malloc(sizeof(int) *n);
    for(i=0;i<n;i++)
    {
        printf("\n Enter Value :" );
        scanf("%d",(p+i));
    }
    sort(p,n);
    getch();
}
sort(int *p,int n)
{
    int i,j,k;
    for(i=0;i<n;i++)
    {
        for(j=0;j<(n-1);j++)
        {
            if(*(p+j) > *(p+(j+1)))
            {
                k = *(p+j);
                *(p+j) = *(p+(j+1));
                *(p+(j+1)) = k;
            }
        }
    }
    for(i=0;i<n;i++)
    {
        printf("\n Value is  : %d",*(p+i));
    }
}

Program to create a binary tree and produce the output using all three traversal methods of binary tree.

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

struct abc
{
    int info;
    struct abc *left,*right;
};
struct abc *root = NULL, *node,*p,*q;
void main()
{
    int ch;
    do
    {
        clrscr();
        printf("\n Binary Tree");
        printf("\n 1. Insert element");
        printf("\n 2. Preorder Traversal");
        printf("\n 3. Inorder Traversal");
        printf("\n 4. Postorder Traversal");
        printf("\n 5. Exit");
        printf("\n Enter your choice :");
        scanf("%d",&ch);
        switch(ch)
        {
            case 1:
                insert();
                getch();
                continue;
            case 2:
                p = root;
                preorder(p);
                getch();
                continue;
            case 3:
                p = root;
                inorder(p);
                getch();
                continue;
            case 4:
                p = root;
                postorder(p);
                getch();
                continue;
        }
    }while(ch!=5);
}
insert()
{
    node = (struct abc *) malloc(sizeof(struct abc));
    printf("\n Enter element : ");
    scanf("%d",&node->info);
    if(root == NULL)
    {
        root = node;
        node->left = NULL;
        node->right = NULL;
        return;
    }
    p = root;
    find(p);
    return;
}
find( struct abc *p)
{
    if(node->info < p->info)
    {
        if(p->left != NULL)
            find(p->left);
        else
        {
            p->left = node;
            node->left = NULL;
            node->right = NULL;
            return;
        }
    }
    else if(node->info > p->info)
    {
        if(p->right != NULL)
            find(p->right);
        else
        {
            p->right = node;
            node->left = NULL;
            node->right = NULL;
            return;
        }
    }
    else
    {
        printf("\n Duplicate Element not allowed");
        return;
    }
    return;
}
preorder(struct abc *p)
{
    printf("\n Element is : %d",p->info);
    if(p->left != NULL)
        preorder(p->left);
    if(p->right != NULL)
        preorder(p->right);
    return;
}
inorder(struct abc *p)
{

    if(p->left != NULL)
        inorder(p->left);
    printf("\n Element is : %d",p->info);
    if(p->right != NULL)
        inorder(p->right);
    return;
}
postorder(struct abc *p)
{
    if(p->left != NULL)
        postorder(p->left);
    if(p->right != NULL)
        postorder(p->right);
    printf("\n Element is : %d",p->info);
    return;
}

C Program For The BinarySearch

#include<stdio.h>
#include<conio.h>
// Binary search
void main()
{
    int x[10],low,high,mid,y,i,j,k;
    clrscr();
    for(i=0;i<=9;i++)
    {
        printf("\n Enter value :");
        scanf("%d",&x[i]);
    }
    for(i<=0;i<=9;i++)
    {
        for(j=i+1;j<=9;j++)
        {
            if(x[i] > x[j])
            {
                k=x[i];
                x[i]=x[j];
                x[j] = k;
            }
        }
    }
    printf("\n Enter value to search :");
    scanf("%d",&y);
    high = 10;
    low =0;
    while(low <= high)
    {
        mid = (low + high) /2;
        if(y < x[mid])
            high = mid -1;
        else if(y>x[mid])
            low = mid +1;
        else
        {
            printf("\n Element found on %dth location ",mid+1);
            break;
        }
    }
}

Mar 29, 2011

Increase Internet Download Connections

Increase Simultaneous Internet Download Connections. Increases the number of allowed simultaneous connections to ten (10).

[Start] [Run] [Regedit]

Go to: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings

Modify/Create DWORD Value of Data type REG_DWORD Named [MaxConnectionsPer1_0Server]
Setting for Value Data: [0000000a]

Modify/Create DWORD Value of Data type REG_DWORD Named [MaxConnectionsPerServer]
Setting for Value Data: [0000000a]

Exit Registry / Reboot

Create a Hidden User Account

This tweak allows an account that is normally displayed on the Welcome screen to be hidden from view. To log on using the account it's necessary to use the Log On To Windows dialog box similar to the one in Windows 2000 i.e. press CTRL+ALT+DEL twice.

[Start] [Run] [Regedit]

Go to: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Winlogon\SpecialAccounts\UserList

Modify/Create DWORD Value of Data type REG_DWORD Named [Type Name of Account to be Hidden]
Setting for Value Data: [0 = Account is Hidden / 1 = Enabled]

Exit Registry / Reboot

While the account is hidden on the Welcome screen, note that the account profile will be visible in C:\Documents and Settings or wherever user profiles are stored as well as in Local Users and Groups.

Enable/Disable Save Password in DUN

This tweak saves user passwords for Dial Up Networking so they do not have to be re-entered each session.

[Start] [Run] [Regedit]

Go to: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\RasMan\Parameters

Modify/Create DWORD Value of Data type REG_DWORD Named [DisableSavePassword]
Setting for Value Data: [0 = Disabled (Passwords Saved) / 1 = Enabled (Passwords Not Saved)]

Exit Registry / Reboot

Mar 26, 2011

How to Run RMI Program?

To Run follow following Step
----------------------------------
D:\RMI\Prog1>javac *.java

D:\RMI\Prog1>rmic myRmiImpl

D:\RMI\Prog1>start rmiregistry

D:\RMI\Prog1>start java -classpath . -Djava.security.policy=java.policy myRmiServer

D:\RMI\Prog1>java -classpath . -Djava.security.policy=java.policy myRmiClient 127.0.0.1

Deleting value from a Linear Array at Specified Position.

# define s 20

char employ[s][s];
int delete_array(char employ[s][s], int, int, char *);
void input(char emply[s][s], int );
void display(char employ[s][s], int );

/* Definition of the function */

int delete_array(char employ[s][s], int number, int position, char element[])
{
int temp = position;
element = employ[position];
printf("\n Information which we have to delete: %s", element);

while( temp <= number-1)
{
*employ [temp] = *employ[temp+1];
temp ++;
}
number = number - 1 ;
return(number);
}

void input(char employ[s][s], int number)
{
int i;
for(i = 1; i<= number ; i++)
{
fflush(stdin);
printf("\n Input value for: %d: ", i);
gets(employ[i]);
}
}

void display(char employ[s][s], int number)
{
int i;
for(i = 1; i<= number; i++)
{
printf("\n Value at the position: %d: %s", i, employ[i]);
}
}

/* main function */

void main()
{
int number;
int position;
char element[s];

printf("\n Input the number of elements in the array:");
scanf("%d", &number);
fflush(stdin);
input(employ, number);
printf("\n Entered list is as follows:\n");

display(employ, number);
fflush(stdin);
printf("\n Input the position from where you want delete an element:");
scanf("%d", &position);

number = delete_array(employ, number, position, element);
display(employ,number);
}

Inserting value in a Linear Array at Specified Position.


int insert_array(char *, int, int, char);
void input(char *, int );
void display(char *, int );

/* Definition of the function */

int insert_array(char array[], int number, int position, char element)
{
int temp = number;
while( temp >= position)
{
array[temp+1] = array[temp];
temp --;
}

array[position] = element;
number = number +1 ;
return(number);
}

/* INPUT FUNCTION TO READ DATA */

void input(char array[], int number)
{
int i;
for(i = 1; i<= number ; i++)
{
fflush(stdin);
printf("\n Input value for: %d: ", i);
scanf("%c", &array[i]);
}
}

/* OUTPUT FUNCTION TO PRINT ON THE CONSOLE */

void display(char array[], int number)
{
int i;
for(i = 1; i<= number; i++)
{
printf("\n Value at the position: %d: %c ", i, array[i]);
}
}

/* main function */

void main()
{
int number;
char array[100];
int position;
char element;
fflush(stdin);
printf("\n Input the number of element into the LIST: ");
scanf("%d", &number);
fflush(stdin);
input(array, number);
printf("\n Entered list as follows:\n");
fflush(stdin);
display(array,number);
fflush(stdin);
printf("\n Input the position where you want add a new data:");
scanf("%d", &position);
fflush(stdin);
printf("\n Input the value for the position:");
scanf("%c", &element);
number = insert_array(array,number,position,element);
display(array,number);
}

Traversing a linear array.


void memory(int *, int, int);
void memory1(char *, int, int);

/* Definition of the function memory */

void memory(int a[], int l_b, int u_b)
{
int counter;

for(counter = l_b; counter<=u_b; counter++)
{
printf("\n Element at location: 0x%x is %d", &a[counter], a[counter]);
}
printf("\n Array size = %d ", &a[counter-1] - &a[0] + 1);
}

void memory1(char b[], int l_b, int u_b)
{
char *pointer;
int counter;
pointer =&b[0];

for(counter = l_b; counter<=u_b; counter++)
{
printf("\n Element at location: 0x%x is %d", &b[counter], b[counter]);
}
printf("\n Array size = %d", &b[counter-1] - &b[0] + 1);
}

/*Function main */

void main()
{
int a[12] = {99,88,77,66,55,44,33,22,11,100,200,300};
char b[] = {'A','B','C','D','E','F','G','H','I','J','K',
'L','M','N','O','P','Q','R','S','T','U','V',
'W','X','Y','Z' };
int lb=0, ub=11;
memory(a,lb,ub);
lb = 0;
ub = 25;
memory1(b,lb,ub);
}

Deleting Duplicate from a linear array.

int status ;
int dup;
int duplicate_array(int *, int);
void input(int *, int );
void display(int *, int );

/* Definition of the function */

int duplicate_array(int array[], int number)
{
int i, j, k;
status = 0;
dup = number;

for(i = 0; i< number-1; i++)
for(j = i+1; j< number; j++)
{
if(array[i] == array[j])
{
number = number - 1 ;
for(k = j; k
array[k] = array[k+1];
status = 1;
j = j - 1;
}
}
if( status ==0)
printf("\n No duplicate is found");
return(dup-number);
}

/* Input function to read data */

void input(int array[], int number)
{
int i;
for(i = 0; i< number ; i++)
{
printf("Input value for: %d: ", i+1);
scanf("%d", &array[i]);
}
}

/* Output function */

void display(int array[], int number)
{
int i;
for(i = 0; i< number; i++)
{
printf("\n Value at the position: %d: %d", i+1, array[i]);
}
}

/* main function */

void main()
{
int number;
int array[100];
int n;
printf("\n Input the number of elements in the list: ");
scanf("%d", &number);
input(array, number);
printf("\n Entered list is as follows:\n");

display(array,number);

n = duplicate_array(array,number);
printf("\nNumber of duplicate elements in the list are: %d", n);
printf("\nAfter removing duplicates from the list, the list is as follows:");
display(array,number-n);

Find a Inverse of a Matrix.


int i, j;

void display( int, int, float mat[10][10],float mat1[10][10]);
void input( int, int, float mat[10][10],float mat1[10][10]);
Inverse_Mat(int , int, float mat[10][10],float mat1[10][10]);
void swap(int, int, int, float mat[10][10],float mat1[10][10]);

/* This function exchange two rows of a matrix */

void swap( int row1,int row2, int col, float mat[10][10],float mat1[10][10])
{
for( i = 0; i < col; i++)
{
float temp = mat[row1][i];
mat[row1][i] = mat[row2][i];
mat[row2][i] = temp;

temp = mat1[row1][i];
mat1[row1][i] = mat1[row2][i];
mat1[row2][i] = temp;

}
}

/* This function find inverse of matrix */

int Inverse_Mat(int row1, int col1, float mat[10][10],float mat1[10][10])
{
int singular = 0;
int r, c;
for(r = 0;( r < row1)&& !singular; r++)
{

if( mat[r][r] ) /* Diagonal element is not zero */
for(c = 0; c < col1; c++)

if( c == r)
{

/* Make all the elements above and below the current principal
diagonal element zero */

float ratio = mat[r][r];
for( i = 0; i < col1; i++)
{
mat[r][i] /= ratio ;
mat1[r][i] /= ratio;
}
}
else
{
float ratio = mat[c][r] / mat[r][r];
for( i = 0; i < col1; i++)
{
mat[c][i] -= ratio * mat[r][i];
mat1[c][i] -= ratio * mat1[r][i];
}
}

else
{
/* If principal diagonal element is zero */
singular = 1;

for(c = (r+1); (c < col1) && singular; ++c)

if(mat[c][r])
{
singular = 0;
/* Find non zero elements in the same column */
swap(r,c,col1, mat, mat1);
--r;
}

}
}
return(!singular);
}

/* To print output this is used */

void display( int row, int col, float mat[10][10],float mat1[10][10])
{
printf("\n");
/* Output of inverse Matrix */
for( i = 0; i < row; i++)
{
for( j = 0; j < col; j++)
{
printf(" %f", mat1[i][j]);
}
printf("\n");
}

}

/* input function */

void input( int row, int col, float mat[10][10],float mat1[10][10])
{
for( i = 0 ; i< row; i++)
{
for( j = 0 ; j
{
printf("Input Value for: %d: %d: ", i+1, j+1);
scanf("%f", &mat[i][j]);
mat1[i][j] = 0;
}
mat1[i][i] = 1;
}
printf("\n Entered Matrix is as follows:\n");
for( i = 0; i < row; i++)
{
for( j = 0; j < col; j++)
{
printf(" %f", mat[i][j]);
}
printf("\n");
}
}


/* main function */


void main()
{

int R, C;
float mat[10][10];
float mat1[10][10];
printf("\n Input number of rows:");
scanf("%d", &R);
printf(" Input number of cols:");
scanf("%d", &C);
input(R,C, mat, mat1);

Inverse_Mat(R,C, mat, mat1);
printf("\n Inverse of above matrix is as follows:\n ");
display(R,C, mat, mat1);

Matrix Multiplication in C


# define row 10
# define col 10

int i, j;
int row1, col1;
int row2, col2;
float mat1[row][col];
float mat2[row][col];
float mat_res[row][col];

void mat_mult( float mat1[row][col], int, int,
float mat2[row][col], int, int,
float mat_res[row][col]);

void display(float mat[row][col], int, int);
void input(float mat[row][col], int , int);

/* function to multiply two matrices */

void mat_mult( float mat1[row][col], int row1, int col1,
float mat2[row][col], int row2, int col2,
float mat_res[row][col])
{
int i, j, k;
if(col1 == row2)
{
printf("\n Multiplication is possible and Result is as follows\n");

for(i =0; i< col1; k ++) { mat_res[i][j] += mat1[i][k] * mat2[k][j]; } } display(mat_res, row1, col2); } else printf("\n Multiplication is not possible"); exit(0); } /* Output function */ void display(float mat[row][col], int r, int c ) { for( i = 0; i < r; i++) { for( j = 0; j < c; j++) { printf(" %f", mat[i][j]); } printf("\n"); } } /* Input function */ void input(float mat[row][col], int r, int c) { for( i = 0 ; i< r; i++) { for( j = 0 ; j1:"); scanf("%d", &row1); printf("\n Input the col of the matrix->1:");
scanf("%d", &col1);

printf("\n Input data for matrix-> 1\n");
input(mat1, row1, col1);

printf("\n Input the row of the matrix ->2:");
scanf("%d", &row2);

printf("\n Input the col of the matrix->2:");
scanf("%d", &col2);

printf("\n Input data for matrix-> 2\n");
input(mat2, row2, col2);

printf("\n Entered Matrix First is as follows:\n");
display(mat1,row1,col1);

printf("\n Entered Matrix Two is as follows:\n");
display(mat2,row2,col2);

mat_mult(mat1 ,row1 ,col1, mat2, row2, col2, mat_res);
}

Find a Rank of Matrix.

int R,C;
int i, j;
int mat[10][10];

void display( int, int);
void input( int, int);
int Rank_Mat(int , int);
void swap(int, int, int);

/* This function exchange two rows of a matrix */

void swap( int row1,int row2, int col)
{
for( i = 0; i < col; i++)
{
int temp = mat[row1][i];
mat[row1][i] = mat[row2][i];
mat[row2][i] = temp;
}
}

/* This function find rank of matrix */

int Rank_Mat(int row1, int col1)
{
int r, c;
for(r = 0; r< col1; r++)
{
display(R,C);
if( mat[r][r] ) // Diagonal element is not zero
for(c = 0; c < row1; c++)
if(c != r)
{
/* Make all the elements above and below the current principal
diagonal element zero */

float ratio = mat[c][r]/ mat[r][r];
for( i = 0; i < col1; i++)
mat[c][i] -= ratio * mat[r][i];
}

else
printf("\n");

/* Principal Diagonal elment is zero */

else
{
for(c = r+1 ; c < row1; c++)
if (mat[c][r])
{
/* Find non zero elements in the same column */
swap(r,c,col1);
break ;
}

if(c == row1)
{
-- col1;

for(c = 0; c < row1; c ++)
mat[c][r] = mat[c][col1];
}
--r;
}
}
return col1;
}

/* Output function */

void display( int row, int col)
{
for(i = 0; i < row; i++)
{
for(j = 0; j < col; j++)
{
printf(" %d", mat[i][j]);
}
printf("\n");
}
}

/* Input function */

void input( int row, int col)
{
int value;
for(i = 0 ; i< row; i++)
{
for(j = 0 ; j
{
printf("Input Value for: %d: %d: ", i+1, j+1);
scanf("%d", &value);
mat[i][j] = value;
}
}
}

/* main function */

void main()
{
int rank;
printf("\n Input number of rows:");
scanf("%d", &R);
printf("\n Input number of cols:");
scanf("%d", &C);
input(R, C);
printf("\n Row is : %d", R);
printf("\n Column is : %d \n", C);

printf("\n Entered Two Dimensional array is as follows:\n");
display(R,C);
printf("\n Row is : %d", R);
printf("\n Column is : %d\n", C);

rank = Rank_Mat(R, C);
printf("\n Rank of above matrix is : %d", rank);
}

Mar 16, 2011

Machine language:-

The set of instruction codes, whether binary or in decimal notation, which can be directly understood by the computer without the help of translating program is called Machine code or Machine language program.
Computer can be programmed to understand much different computer language there is only one language understood by the computer without any translation program which: Machine code
Machine code is fundamental language of computer and is written in string of 0’s & 1’s.
An instruction prepared in any machine language has two parts:
(1) OPCODE (operation code)
(2) OPERAND (address location memory)
Advantage:
(1) Fastest execution:
A program written in machine language can be executed very fast by the computer as CPU graphs it easily.
Disadvantages:
(1) Machine dependent:
The internal design of every type of computer is different from every other     type of computer and needs different electrical signals to operate; machine language is different from computer to computer.
(2) Difficult to program:
It is necessary for the programmer either to memorize the dozens of codes for commands or to constantly refer to a reference card for preparing program the has to keep track of the storage location of data.
(3) Error prone:
As the programmer has to keep track of the storage location of data it becomes very difficult for him to concentrate fully on the logic of the problem. This results in error.
(4) Difficult to modify:
It is difficult to correct or modify machine language programs to correct it is a tedious job. Modifying a machine language program at a later date is so difficult that many programmers would prefer to code the new logic a fresh instead of incorporating the necessary modification.

what is a program and programming language?

Program:
Program is a set of well defines instructions, which are tobe process or manipulated for getting predefined and meaningful output.
Programming language:
All computer languages can be classified in the following three broad categories:
(a) Machine language
(b) Assembly language
(c) High level language

Mar 14, 2011

Advantage & Disadvantage of Circular List over Singly linked list

Advantage:


            1.   It is concerned with the accessibility of a node.
            2.   In Circular list every node is accessible from given node.
                   i.e.: -
    From this given node all nodes can be reached by many changing through the list.
3.   It concerns the deletion operation. In singly linked list to delete     desired node, it is necessary to give the address of first node of the list.
4.     This necessity result from the fact that in order to delete desired node. The predecessor of this node has to be found.
5.     To find the predecessor required that a search could be carried out by changing through node from the first node of the list such requirement doesn’t exist for circular list.
 
Disadvantage: 

1.  It is possible that without some care in processing, it is possible to get in to an infinite loop.