Jul 21, 2011

Speed up your internet by 20%

Microsoft reserves 20% of your available bandwidth for their own purposes like Windows Updates and interrogating your PC etc

You can get it back:

Click Start then Run and type "gpedit.msc" without quotes. This opens the group policy editor.

Then go to:
--> Local Computer Policy
--> Computer Configuration
--> Administrative Templates

--> Network

--> QOS Packet Scheduler

--> Limit Reservable Bandwidth.

Double click on Limit Reservable bandwidth.

It will say it is not configured, but the truth is under the 'Explain' tab i.e." By default, the Packet Scheduler limits the system to 20 percent of the bandwidth of a connection, but you can use this setting to override the default."
So the trick is to ENABLE reservable bandwidth, then set it to ZERO. This will allow the system to reserve nothing, rather than the default 20%.It works on Win 2000 as well.

Increase your RAM and so system speed

1). Start any application, say Word. Open some large documents.


2). Press CTRL+SHIFT+ESC to open Windows Task Manager and click Processes tab and sort the list in descending order on Mem Usage. You will notice that WINWORD.EXE will be somewhere at the top, using multiple MBs of memory.



3). Now switch to Word and simply minimize it. (Don't use the Minimize All Windows option of the task bar).



4). Now go back to the Windows Task Manager and see where WINWORD.EXE is listed. Most probably you will not find it at the top. You will typically have to scroll to the bottom of the list to find Word. Now check out the amount of RAM it is using. Surprised? The memory utilization has reduced by a huge amount.



5). Minimize each application that you are currently not working on by clicking on the Minimize button & you can increase the amount of available RAM by a substantial margin. Depending upon the number and type of applications you use together, the difference can be as much as 50 percent of extra RAM.

In any multitasking system, minimizing an application means that it won't be utilized by the user right now. Therefore, the OS automatically makes the application use virtual memory & keeps bare minimum amounts of the code in physical RAM.

Apr 2, 2011

Write a program to perform all operations on singly Circular linked list

#include
#include
struct abc
{
int info;
struct abc *link;
};
struct abc *f = NULL, *prev = NULL;
void main()
{
int ch;
do
{
clrscr();
printf("\n Linked list");
printf("\n 1. Insert");
printf("\n 2. Display");
printf("\n 3. Delete ");
printf("\n 4. Search");
printf("\n 5. Exit");
printf("\n Enter your choice :");
scanf("%d",&ch);
switch(ch)
{
case 1:
insert();
getch();
continue;
case 2:
display();
getch();
continue;
case 3:
delete();
getch();
continue;
case 4:
search();
getch();
continue;
}
}while(ch!= 5);
}
insert()
{
struct abc *new;
new = (struct abc *) malloc(sizeof(struct abc));
printf("\n Enter value :");
scanf("%d",&new->info);
if(f==NULL && prev == NULL)
{
f=new;
prev= new;
new->link = f;
return;
}
prev->link = new;
new->link = f;
prev = new;
return;
}
display()
{
struct abc *x;
if(f==NULL && prev == NULL)
{
printf("\n Linked List is Empty");
return;
}
x=f;
do
{
printf("\n Value is : %d", x->info);
x = x->link;
}while(x!=f);
return;
}
delete()
{
struct abc *p,*q;
int x;
if(f==NULL && prev == NULL)
{
printf("\n Linked List is Empty");
return;
}
printf("\n Enter element to delete : ");
scanf("%d",&x);
if(f->info == x && f == prev)
{
f = NULL;
prev = NULL;
return;
}
if(f->info == x)
{
f = f->link;
prev->link = f;
return;
}
p=f;
do
{
q=p;
p=p->link;
}while(p!=f && p->info != x);

if(p->info == x && p == prev)
{
q->link = p->link;
prev = q;
return;
}
if(p->info == x)
{
q->link = p->link;
return;
}
printf("\n Element not found in the list ");
return;
}
search()
{

struct abc *p,*q;
int x,flag=0;
if(f==NULL && prev == NULL)
{
printf("\n Linked List is Empty");
return;
}
printf("\n Enter element to search : ");
scanf("%d",&x);
p=f;
do
{
if(p->info == x)
{
flag = 1;
break;
}
p=p->link;
}while(p!= f);
if(flag)
printf("\n Element found in the list ");
else
printf("\n Element not found in the list ");
return;
}

Write a program to perform all operations on singly unordered linked list

#include
#include
struct abc
{
int info;
struct abc *link;
};
struct abc *f = NULL, *prev = NULL;
void main()
{
int ch;
do
{
clrscr();
printf("\n Linked list");
printf("\n 1. Insert");
printf("\n 2. Display");
printf("\n 3. Delete ");
printf("\n 4. Search");
printf("\n 5. Sort");
printf("\n 6. Exit");
printf("\n Enter your choice :");
scanf("%d",&ch);
switch(ch)
{
case 1:
insert();
getch();
continue;
case 2:
display();
getch();
continue;
case 3:
delete();
getch();
continue;
case 4:
search();
getch();
continue;
case 5:
sort();
getch();
continue;
}
}while(ch!= 6);
}
insert()
{
struct abc *new;
new = (struct abc *) malloc(sizeof(struct abc));
printf("\n Enter value :");
scanf("%d",&new->info);
if(f==NULL && prev == NULL)
{
f=new;
prev= new;
new->link = NULL;
return;
}
prev->link = new;
new->link = NULL;
prev = new;
return;
}
display()
{
struct abc *x;
if(f==NULL && prev == NULL)
{
printf("\n Linked List is Empty");
return;
}
x=f;
while(x!=NULL)
{
printf("\n Value is : %d", x->info);
x = x->link;
}
return;
}
delete()
{
struct abc *p,*q;
int x;
if(f==NULL && prev == NULL)
{
printf("\n Linked List is Empty");
return;
}
printf("\n Enter element to delete : ");
scanf("%d",&x);
if(f->info == x && f == prev)
{
f = NULL;
prev = NULL;
return;
}
if(f->info == x)
{
f = f->link;
return;
}
p=f;
while(p!=NULL && p->info != x)
{
q=p;
p=p->link;
}
if(p->info == x && p == prev)
{
q->link = p->link;
prev = q;
return;
}
if(p->info == x)
{
q->link = p->link;
return;
}
printf("\n Element not found in the list ");
return;
}
search()
{

struct abc *p,*q;
int x,flag=0;
if(f==NULL && prev == NULL)
{
printf("\n Linked List is Empty");
return;
}
printf("\n Enter element to search : ");
scanf("%d",&x);
p=f;
while(p!=NULL)
{
if(p->info == x)
{
flag = 1;
break;
}
p=p->link;
}
if(flag)
printf("\n Element found in the list ");
else
printf("\n Element not found in the list ");
return;
}
sort()
{
struct abc *p,*q;
int x;
if(f==NULL && prev == NULL)
{
printf("\n Linked List is Empty");
return;
}
for(p=f;p!=NULL;p=p->link)
{
for(q=p;q!=NULL;q=q->link)
{
if(p->info > q->info)
{
x = p->info;
p->info = q->info;
q->info = x;
}
}
}
display();
return;
}

Write a program to perform all operations on singly ordered linked list

#include
#include
struct abc
{
int info;
struct abc *link;
};
struct abc *f = NULL, *prev = NULL;
void main()
{
int ch;
do
{
clrscr();
printf("\n Linked list");
printf("\n 1. Insert");
printf("\n 2. Display");
printf("\n 3. Delete ");
printf("\n 4. Search");
printf("\n 5. Exit");
printf("\n Enter your choice :");
scanf("%d",&ch);
switch(ch)
{
case 1:
insert();
getch();
continue;
case 2:
display();
getch();
continue;
case 3:
delete();
getch();
continue;
case 4:
search();
getch();
continue;
}
}while(ch!= 5);
}
insert()
{
struct abc *new,*p,*q;
new = (struct abc *) malloc(sizeof(struct abc));
printf("\n Enter value :");
scanf("%d",&new->info);
if(f==NULL && prev == NULL)
{
f=new;
prev= new;
new->link = NULL;
return;
}
if(new->info <=f->info)
{
new->link = f;
f=new;
return;
}
if(new->info >= prev->info)
{
prev->link = new;
new->link = NULL;
prev = new;
return;
}
p =f;
while(p->info <= new->info)
{
q=p;
p=p->link;
}
q->link = new;
new->link = p;
return;
}
display()
{
struct abc *x;
if(f==NULL && prev == NULL)
{
printf("\n Linked List is Empty");
return;
}
x=f;
while(x!=NULL)
{
printf("\n Value is : %d", x->info);
x = x->link;
}
return;
}
delete()
{
struct abc *p,*q;
int x;
if(f==NULL && prev == NULL)
{
printf("\n Linked List is Empty");
return;
}
printf("\n Enter element to delete : ");
scanf("%d",&x);
if(f->info == x && f == prev)
{
f = NULL;
prev = NULL;
return;
}
if(f->info == x)
{
f = f->link;
return;
}
p=f;
while(p!=NULL && p->info != x)
{
q=p;
p=p->link;
}
if(p->info == x && p == prev)
{
q->link = p->link;
prev = q;
return;
}
if(p->info == x)
{
q->link = p->link;
return;
}
printf("\n Element not found in the list ");
return;
}
search()
{

struct abc *p,*q;
int x,flag=0;
if(f==NULL && prev == NULL)
{
printf("\n Linked List is Empty");
return;
}
printf("\n Enter element to search : ");
scanf("%d",&x);
p=f;
while(p!=NULL)
{
if(p->info == x)
{
flag = 1;
break;
}
p=p->link;
}
if(flag)
printf("\n Element found in the list ");
else
printf("\n Element not found in the list ");
return;
}

mkdir

mkdir command is used to create directories. The command is followed by the names of the directories to be created.

$ mkdir virani

This command creates the directories virani

$ mkdir stud1 stud2 stud3

This command will create three directories stud1,stud2,and stud3.

$ mkdir virani virani/sci virani/arts

This creates three directories virani,two sub directories sci and arts under virani.The order of specifying arguments is important; you obviously can’t create a sub directory before creation of its parent directory.

Sometimes the system refuses to create a directory:

$mkdir maths

mkdir : can’t make directory maths

This can happen due to these reasons:
• The directory maths may already exist.
• There may be an ordinary file by that name in the current directory.
• The user doesn’t have the permission to create a directory.

who am i

The who command ,when used with the arguments “am” and “I”, displays a single line output only,i.e the login detail pertaining to the user who invoked this command.


$ who am i
vsc tty01 Dec 25 09:35

who command

who command gives the list of the users currently working on various terminals.
$who
vsc tty01 Dec 25 09:35
atmiya tty02 Dec 25 08:50
student tty03 Dec 25 09:45

$who –Hu

USER LINE LOGIN-TIME IDLE PID COMMENTS

vsc tty01 Dec 25 09:35 . 24
student tty02 Dec 25 09:40 0:30 25

-H is for header and –u option provides more detailed list
The idle column shows that student seems to be idling for last6 30 minutes. PID shows the process identification number.

passwd command



passwd command is used to change passwords
$ passwd
old password:
new password:
Re-enter new password:

            Passwd when invoked by ordinary user ,it asks for old password. After which it demands to enter new password twice. if you are logged on as root you can directly change the password.

In Linux
[root@localhost]passwd vsc
changing password for vsc
new password:

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.