theme

" जीतने वाले छोड़ते नहीं और छोड़ने वाले जीतते नही "

Sunday, October 9, 2011

Jan Lokpal Bill

Jan Lokpal Bill Anna Hazare .mp3
Found at bee mp3 search engine

Tuesday, September 27, 2011

hhgk

Monday, September 12, 2011

जल -जले की खौफ से क्या घर बनाना छोड़ दे..
और हादसो की जख्म से क्या मुस्कुराना छोड़ दे..??
                                  ---------अमित राय

Wednesday, July 6, 2011

doubly linked list in c

#include
#include
        struct node
        {
        int data;
        struct node *next;
        struct node *prev;
        }*start,*last,*newnode,*p,*ptr;
void main()
{
int ch;
clrscr();
    do
    {
    printf("**********MAIN MENU***********");
    printf("\n1.add start");
    printf("\n2.add middle");
    printf("\n3.addlast");
    printf("\n4.delete");
    printf("\n5.show");
    printf("\n6.count");
    printf("\n7.search");
    printf("\n8.sort");
    printf("\n9.reverse");
    printf("\n0.exit");
    printf("\nenter your choice");
    scanf("%d",&ch);
switch(ch)
{
case 1 : addstart();break;
case 2 : addmiddle();break;
case 3 : addlast();break;
case 4 : deldata();break;
case 5 : show();break;
case 6 : count();break;
case 7 : search();break;
case 8 : sort();break;
case 9 : reverse(); break;
case 0 : break;
default:printf("wrong choice");break;
}
}while(ch!=0);
}
    addstart()
    {
    struct node *newnode;
    newnode=(struct node*)malloc(sizeof(struct node));
    printf("enter the data");
    scanf("%d",&newnode->data);
    newnode->next=NULL;
    newnode->prev=NULL;
    if(start==NULL)
    {
    start=newnode;
    last=newnode;
    }
    else
    {
    start->prev=newnode;
    newnode->next=start;
    start=newnode;
    }
    }
addlast()
{
struct node *newnode;
newnode=(struct node*)malloc(sizeof(struct node));
printf("enter the data");
scanf("%d",&newnode->data);
newnode->next=NULL;
newnode->prev=NULL;
if(start==NULL)
{
start=newnode;
last=newnode;
}
else
{
last->next=newnode;
newnode->prev=last;
last=newnode;
}
}
    show()
    {
    for(p=start;p!=NULL;p=p->next)
    {
    printf("%d",p->data);
    }
    }
count()
{
int c=0;
for(p=start;p!=NULL;p=p->next)
{
c++;
}
printf("%d",c);
}
    addmiddle()
    {
    int n;
    struct node *newnode;
    newnode=(struct node*)malloc(sizeof(struct node));
    printf("enter the data");
    scanf("%d",&newnode->data);
    newnode->next=NULL;
    newnode->prev=NULL;
    if(start==NULL)
    {
    start=newnode;
    last=newnode;
    }
    else
    {
    printf("enter data after which u want to add");
    scanf("%d",&n);
    for(p=start;p!=NULL;p=p->next)
    {
    if(p->data==n)
    {
    p->next->prev=newnode;
    newnode->next=p->next;
    newnode->prev=p;
    p->next=newnode;
    break;
    }
    }
    }
    }
search()
{
int n,flag=0,c=0;
printf("enter data to search");
scanf("%d",&n);
for(p=start;p!=NULL;p=p->next)
{
if(p->data==n)
{
flag=1;
c++;
break;
}
else
c++;
}
if(flag==1)
printf("found on %d",c);
else
printf("not found");
}
    deldata()
    {
    int n;
    printf("enter no to delete");
    scanf("%d",&n);
    if(start==NULL)
    {
    printf("no data to delete");
    }
    else
    {
    for(p=ptr=start;p!=NULL;p=p->next)
    {
    if(p->data==n)
    {
    if(p==start)
    {
    start=p->next;
    start->prev=NULL;
    free(p);
    break;
    }
    else if(p==last)
    {
    last=p->prev;
    last->next=NULL;
    free(p);
    break;
    }
    else
    {
    p->next->prev=p->prev;
    p->prev->next=p->next;
    free(p);
    break;
}
}
}
}
}
sort()
{
int t;
p=start;
do
{
ptr=start;
do
{
if(ptr->data>ptr->next->data)
{
t=ptr->data;
ptr->data=ptr->next->data;
ptr->next->data=t;
}
ptr=ptr->next;
}while(ptr->next!=NULL);
p=p->next;
}while(p!=NULL);
}
reverse()
{
for(p=last;p!=NULL;p=p->prev)
{
printf("%d",p->data);
}
}


program of singlelinklist in c

#include
#include
struct node
{
int data;
struct node *next;
}*start,*last,*newnode,*p,*ptr;
void main()
{
int ch;
clrscr();
do
{
printf("**********MAIN MENU***********");
printf("\n1.add start");
printf("\n2.add middle");
printf("\n3.addlast");
printf("\n4.delete");
printf("\n5.show");
printf("\n6.count");
printf("\n7.search");
printf("\n8.sort");
printf("\n9.exit");
scanf("%d",&ch);
switch(ch)
{
case 1 : addstart();break;
case 2 : addmiddle();break;
case 3 : addlast();break;
case 4 : deldata();break;
case 5 : show();break;
case 6 : count();break;
case 7 : search();break;
case 8 : sort();break;
case 9 : break;
default:printf("wrong choice");break;
}
}while(ch!=9);
}
addstart()
{
struct node *newnode;
newnode=(struct node*)malloc(sizeof(struct node));
printf("enter the data");
scanf("%d",&newnode->data);
newnode->next=NULL;
if(start==NULL)
{
start=newnode;
last=newnode;
}
else
{
newnode->next=start;
start=newnode;
}
}
addlast()
{
struct node *newnode;
newnode=(struct node*)malloc(sizeof(struct node));
printf("enter the data");
scanf("%d",&newnode->data);
newnode->next=NULL;
if(start==NULL)
{
start=newnode;
last=newnode;
}
else
{
last->next=newnode;
last=newnode;
}
}
show()
{
for(p=start;p!=NULL;p=p->next)
{
printf("%d",p->data);
}
}
count()
{
int c=0;
for(p=start;p!=NULL;p=p->next)
{
c++;
}
printf("%d",c);
}
addmiddle()
{
int n;
struct node *newnode;
newnode=(struct node*)malloc(sizeof(struct node));
printf("enter the data");
scanf("%d",&newnode->data);
newnode->next=NULL;
if(start==NULL)
{
start=newnode;
last=newnode;
}
else
{
printf("enter data after which u want to add");
scanf("%d",&n);
for(p=start;p!=NULL;p=p->next)
{
if(p->data==n)
{
newnode->next=p->next;
p->next=newnode;
break;
}
}
}
}
search()
{
int n,flag=0,c=0;
printf("enter data to search");
scanf("%d",&n);
for(p=start;p!=NULL;p=p->next)
{
if(p->data==n)
{
flag=1;
c++;
break;
}
else
c++;
}
if(flag==1)
printf("found on %d",c);
else
printf("not found");
}
deldata()
{
int n;
printf("enter no to delete");
scanf("%d",&n);
for(p=ptr=start;p!=NULL;ptr=p,p=p->next)
{
if(p->data==n)
{
if(p==start)
{
start=p->next;
free(p);
break;
}
else if(p==last)
{
ptr->next=NULL;
last=ptr;
free(p);
break;
}
else
{
ptr->next=p->next;
free(p);
break;
}
}
}
}
sort()
{
int t;
p=start;
do
{
ptr=start;
do
{
if(ptr->data>ptr->next->data)
{
t=ptr->data;
ptr->data=ptr->next->data;
ptr->next->data=t;
}
ptr=ptr->next;
}while(ptr->next!=NULL);
p=p->next;
}while(p!=NULL);
}






queue program in c

#include
#include
int queue[10];
int rear=-1;
int front=-1;
void main()
{
int ch;
clrscr();
do
{
printf("**********MAIN MENU***********");
printf("\n1.insert");
printf("\n2.deletedata");
printf("\n3.show");
printf("\n4.exit");
printf("\nenter your choice ");
scanf("%d",&ch);
switch(ch)
{
case 1 : insert();break;
case 2 : deletedata();break;
case 3 : show();break;
case 4 : break;
default : printf("wrong choice");break;
}
}while(ch!=4);
}
insert()
{
int n;
printf("enter the data");
scanf("%d",&n);
if(rear==9)
{
printf("queue is overflow");
}
else if(rear==-1)
{
rear++;
front++;
queue[rear]=n;
}
else
{
rear++;
queue[rear]=n;
}
}
deletedata()
{
if(front==-1)
{
printf("queue empty");
}
else if(rear==front)
{
rear=-1;
front=-1;
}
else
{
front++;
}
}
show()
{
int i;
for(i=front;i<=rear;i++)
{
printf("%d",queue[i]);
}
}


programme of circular linklist

#include
#include
struct node
{
int data;
struct node *next;
}*start,*last,*newnode,*p,*ptr;
void main()
{
int ch;
clrscr();
do
{
printf("**********MAIN MENU***********");
printf("\n1.add start");
printf("\n2.add middle");
printf("\n3.addlast");
printf("\n4.delete");
printf("\n5.show");
printf("\n6.count");
printf("\n7.search");
printf("\n8.sort");
printf("\n9.exit");
scanf("%d",&ch);
switch(ch)
{
case 1 : addstart();break;
case 2 : addmiddle();break;
case 3 : addlast();break;
case 4 : deldata();break;
case 5 : show();break;
case 6 : count();break;
case 7 : search();break;
case 8 : sort();break;
case 9 : break;
default:printf("wrong choice");break;
}
}while(ch!=9);
}
addstart()
{
struct node *newnode;
newnode=(struct node*)malloc(sizeof(struct node));
printf("enter the data");
scanf("%d",&newnode->data);
newnode->next=NULL;
if(start==NULL)
{
start=newnode;
last=newnode;
}
else
{
newnode->next=start;
start=newnode;
last->next=newnode;
}
}
addlast()
{
struct node *newnode;
newnode=(struct node*)malloc(sizeof(struct node));
printf("enter the data");
scanf("%d",&newnode->data);
newnode->next=NULL;
if(start==NULL)
{
start=newnode;
last=newnode;
}
else
{
last->next=newnode;
last=newnode;
newnode->next=start;
}
}
show()
{
p=start;
do
{
printf("%d",p->data);
p=p->next;
}while(p!=start);
}
count()
{
int c=0;
p=start;
do
{
c++;
p=p->next;
}while(p!=start);
printf("%d",c);
}
addmiddle()
{
int n;
struct node *newnode;
newnode=(struct node*)malloc(sizeof(struct node));
printf("enter the data");
scanf("%d",&newnode->data);
newnode->next=NULL;
if(start==NULL)
{
start=newnode;
last=newnode;
}
else
{
printf("enter data after which u want to add");
scanf("%d",&n);
p=start;
do
{
if(p->data==n)
{
newnode->next=p->next;
p->next=newnode;
break;
}
p=p->next;
}while(p!=start);
}
}
search()
{
int n,flag=0,c=0;
printf("enter data to search");
scanf("%d",&n);
p=start;
do
{
if(p->data==n)
{
flag=1;
c++;
break;
}
c++;
} while(p!=start);
if(flag==1)
{
printf("found on %d",c);
}
else
printf("not found");
}
deldata()
{
int n;
printf("enter no to delete");
scanf("%d",&n);
if(start==NULL)
printf("no any data to dalete");
else
{
p=start;
ptr=start;
}
do
{
if(p->data==n)
{
if(p==start)
{
start=start->next;
last->next=start;
free(p);
break;
}
else if(p==last)
{
last=ptr;
ptr=start;
free(p);
break;
}
else
{
ptr->next=p->next;
free(p);
break;
}
}
ptr=p;
p=p->next;
}while(p!=start);
}
sort()
{
int t;
p=start;
do
{
ptr=start;
do
{
if(ptr->data>ptr->next->data)
{
t=ptr->data;
ptr->data=ptr->next->data;
ptr->next->data=t;
}
ptr=ptr->next;
}while(ptr->next!=start);
p=p->next;
}while(p!=start);
}




programme of stack in c

#include
#include
int stack[10];
int top=-1;
void main()
{
int ch;
clrscr();
do
{
printf("**********MAIN MENU***********");
printf("\n1.push");
printf("\n2.pop");
printf("\n3.show");
printf("\n4.exit");
printf("\nenter your choice ");
scanf("%d",&ch);
switch(ch)
{
case 1 : push();break;
case 2 : pop();break;
case 3 : show();break;
case 4 : break;
default:printf("wrong choice");break;
}
}while(ch!=4);
}
push()
{
int n;
printf("enter the data");
scanf("%d",&n);
if(top==9)
{
printf("stack is overflow");
}
else
{
top++;
stack[top]=n;
}
}
pop()
{
if(top==-1)
{
printf("stack underflow");
}
else
{
top--;
}
}
show()
{
int i;
for(i=0;i<=top;i++)
{
printf("%d",stack[i]);
}
getch();
}

programme to addition of two polynomial

#include
#include

struct node
{
    int coeff, exp;
    struct node *next;
}*startx, *starty, *startz, *newnode, *p, *x, *y, *z, *last;

main()
{
    int ch;
    clrscr();
    do
    {
        printf("\n\n");
        printf("\n1 insert in x");
        printf("\n2 insert in y");
        printf("\n3 poly add");
        printf("\n4 show list x");
        printf("\n5 show list y");
        printf("\n6 show list z");
        printf("\n7 exit");
        scanf("%d",&ch);

        switch(ch)
        {
            case 1: add_x();
            break;
            case 2: add_y();
            break;
            case 3: poly_add();
            break;
            case 4: list_x();
            break;
            case 5: list_y();
            break;
            case 6: list_z();
            break;
            case 7:
            break;
            default:
            printf("you have inputted wrong value\n");
        }
    }
    while(ch!=7);
}

add_x()
{
    struct node *newnode;
    newnode=(struct node*)malloc(sizeof(struct node));
    newnode->next=NULL;
    printf("enter coeff=");
    scanf("%d", &newnode->coeff);
    printf("enter exp=");
    scanf("%d", &newnode->exp);

    if(x==NULL)
    {
        x=newnode;
        startx=newnode;
    }
    else
    {
        x->next=newnode;
        x=x->next;
    }
}


add_y()
{
    struct node *newnode;
    newnode=(struct node*)malloc(sizeof(struct node));
    newnode->next=NULL;
    printf("enter coeff=");
    scanf("%d", &newnode->coeff);
    printf("enter exp=");
    scanf("%d", &newnode->exp);

    if(y==NULL)
    {
        y=newnode;
        starty=newnode;
    }
    else
    {
        y->next=newnode;
        y=y->next;
    }
}


poly_add()
{
    struct node *newnode;
    newnode=(struct node*)malloc(sizeof(struct node));
    newnode->next=NULL;

    x=startx;
    y=starty;
    while(x!=NULL && y!=NULL)
    {
        if(x->expexp)
        {
            newnode->coeff=y->coeff;
            newnode->exp=y->exp;
            y=y->next;
        }
        else if(x->exp>y->exp)
        {
            newnode->coeff=x->coeff;
            newnode->exp=x->exp;
            x=x->next;
        }
        else if(x->exp==y->exp)
        {
            newnode->coeff=y->coeff+x->coeff;
            newnode->exp=x->exp;
            x=x->next;
            y=y->next;
        }

            if(startz==NULL)
            {
                startz=newnode;
                z=newnode;
            }
            else
            {
                z=z->next;
                z=newnode;

            }
    }
}

list_x()
{
    for(p=startx; p!=NULL; p=p->next)
    {
        printf("%d-%d\t", p->coeff,p->exp);
    }
}

list_y()
{
    for(p=starty; p!=NULL; p=p->next)
    {
        printf("%d-%d\t", p->coeff,p->exp);
    }
}

list_z()
{
    for(p=startz; p!=NULL; p=p->next)
    {
        printf("%d-%d\t", p->coeff,p->exp);
    }
}



































programme to print the binary tree

#include
#include
#include
struct btreenode
{
struct btreenode*leftchild;
int data;
struct btreenode*rightchild;
};
void insert(struct btreenode**,int);
void inorder(struct btreenode*);
void preorder(struct btreenode*);
void postorder(struct btreenode*);
void main()
{
struct btreenode*bt;
int req,i=1,num;
bt=NULL;
clrscr();
printf("specify the number of items to be inserted:");
scanf("%d",&req);
while(i++<=req)
{
printf("enter the data");
scanf("%d",&num);
insert(&bt,num);
}
printf("\ninorder travershal");
inorder(bt);
printf("\n preorder travershal");
preorder(bt);
printf("\n post order travershal");
postorder(bt);
}
void insert(struct btreenode **sr,int num)
{
if(*sr==NULL)
{
*sr=malloc(sizeof(struct btreenode));
(*sr)->leftchild=NULL;
(*sr)->data=NULL;
(*sr)->rightchild=NULL;
return;
}
else
{
if(num<(*sr)->data)
insert(&((*sr)->rightchild),num);
else
insert(&((*sr)->leftchild),num);
}
return;
}
void inorder(struct btreenode*sr)
{
if(sr!=NULL)
{
inorder(sr->leftchild);
printf("\t%d",sr->data);
inorder(sr->rightchild);
}
else
return;
}
void postorder(struct btreenode*sr)
{
if(sr!=NULL)
{
postorder(sr->leftchild);
postorder(sr->rightchild);
printf("\t%d",sr->data);
}
else
return;
}
void preorder(struct btreenode*sr)
{
if(sr!=NULL)
{
printf("\t%d",sr->data);
preorder(sr->leftchild);
preorder(sr->rightchild);
}
else
return;
}


Write a C program to reverse a string.

There are a number of ways one can reverse strings. Here are a few of them. These should be enough to impress the interviewer! The methods span from recursive to non-recursive (iterative).

Also note that there is a similar question about reversing the words in a sentence, but still keeping the words in place. That is


I am a good boy


would become


boy good a am I



------------------------------
.............coding......................

#include
#include
#include

void main()
{
char sh[20],ch[20],hc[20];
int k,i,j,l=0;
clrscr();
printf("enter the string");
gets(ch);
l=strlen(ch);
for(i=l-1;i>=0;i--)
{
if(ch[i]==' ')
{
for(j=i;j<=l;j++)
{
printf("%c",ch[j]);
}
l=i;
}
}
for(k=0;ch[k]!=' ';k++)
      printf("%c",ch[k]);


getch();
}

..................................

Sunday, June 19, 2011

What is throughput? - Definition from Whatis.com

What is throughput? - Definition from Whatis.com तुम्हें मैं भूल जाउंगा ये मुमकिन है नही लेकिन तुम्ही को भूलना सबसे जरूरी है समझता हूँ ....