Monday, April 20, 2015

Quotes and thoughts for peace of mind and to think positive.


“The love of learning, the sequestered nooks, and all the sweet serenity of books” ― Henry Wadsworth Longfellow



“Life is a series of natural and spontaneous changes. Don't resist them; that only creates sorrow. Let reality be reality. Let things flow naturally forward in whatever way they like.” ― Lao Tzu



“There are two ways to get enough. One is to continue to accumulate more and more. The other is to desire less.” ― G.K. Chesterton



“Nothing is so aggravating as calmness.” ― Mahatma Gandhi



“The mind is everything. What you think you become.” – Buddha



“Gratitude is not only the greatest of virtues, but the parent of all others” – Cicero



“For beautiful eyes, look for the good in others; for beautiful lips, speak only words of kindness; and for poise, walk with the knowledge that you are never alone” –Audrey Hepburn



“Forgiveness liberates the soul, it removes fear. That’s why it is such a powerful weapon.” – Nelson Mandela



“Happiness is a state of mind. It’s just according to the way you look at things” – Walt Disney



“The body is the temple of the soul” – Dr. Oz



“You’re even more amazing than you wish you were” – Colin Wright



“When the solution is simple, God is answering” – Albert Einstein



“You yourself, as much as anybody in the entire universe, deserve your love and affection” – Gautama Buddha



“Acceptance is not love. You love a person because he or she has lovable traits, but you accept everybody just because they’re alive and human.” – Albert Ellis



“I bless you with pure love and light. I bless you with purified source energy” – Christie Marie Sheldon



“If you want to be interesting, be interested” – David Ogilvy



“People always ask me: ‘Were you funny as a child?’ Well, no, I was an accountant.” – Ellen DeGeneres



“Hope is being able to see that there is light despite all of the darkness” – Desmond Tutu



“When you say yes, the universe helps you” – Dan Brule



“My philosophy is simple, it is kindness” – Dalai Lama IVX




Share it to make the day of others with feeling of happiness.

Tuesday, April 7, 2015

C program for parenthesized expression using stack

/*PARENTHESIZED EXPRESSION USING STACK */

#include<stdio.h>
#include<conio.h>
#define MAX 10
int top=-1;
int stack[MAX];
void push(char);
char pop();
void main()
{
   char exp[MAX],ch;
   int i,flag=1;
   clrscr();
   printf("\n Enter Infix Expression:-\n");
   gets(exp);
   i=0;
   while(exp[i]!='\0')
   {
     if(exp[i]=='('||exp[i]=='{'||exp[i]=='[')
     {
push(exp[i]);
     }
     if(exp[i]==')'||exp[i]=='}'||exp[i]==']')
     {
       ch=pop();
       if(exp[i]==')'&&(ch=='{'||ch=='['))
       {
flag=0;
       }
       if(exp[i]=='}'&&(ch=='('||ch=='['))
       {
flag=0;
       }
       if(exp[i]==']'&&(ch=='('||ch=='{'))
       {
flag=0;
       }
     }
     i++;
   }
   if(top>=0)
   {
     flag=0;
   }
   if(flag==1)
   {
     printf("\n Valid Expression");
   }
   else
   {
     printf("\n Invalid Expression");
   }
   getch();
}
void push(char c)
{
  if(top==MAX-1)
  {
   printf("\n stack is full");
  }
  else
  {
    top++;
    stack[top]=c;
  }
}
char pop()
{
  char c;
  if(top==-1)
  {
   printf("\n Stack is empty");
  }
  else
  {
   c=stack[top];
   top--;
   return c;
  }
}

C program in stack to concatenate two strings using push and pop functions

#include<stdio.h>
#include<conio.h>
#include<string.h>
#define max 30
void push(char ch);
char pop();
char stack[max];
int top=-1;
void main()
{
char a[20],b[20],k[40],ch;
int i,l1,l2;
clrscr();
printf("\n Enter First String:-\n");
scanf("%s",a);
printf("\n Enter Second String:-\n");
scanf("%s",b);
l1=strlen(a);
l2=strlen(b);
for(i=0;i<l2;i++)
{
 push(b[i]); //push second string into stack
}
push(' ');
for(i=0;i<l1;i++)
{
 push(a[i]); //push first string into stack
}
printf("\n After concatenation of two string:-\n");
i=0;
while(top!=-1)
{
 ch=pop();
 if(ch==' ')
{
k[i]='\0';
printf("%s",strrev(k));
i=0;
 }
else
 {
  k[i]=ch;
  i++;
 }
}
k[i]='\0';
printf("%s",strrev(k));
getch();
}
void push(char ch)
{
if(top==max-1)
{
 printf("\n Stack is full");
}
else
{
 top++;
 stack[top]=ch;
}
}

char pop()
{
char t;
if(top==-1)
{
 printf("\n Stack is Empty");
}
else
{
 t=stack[top];
 top--;
 return(t);
}
}

Monday, April 6, 2015

C program for binary search

#include<stdio.h>
#include<conio.h>
void main()
{
 int a[20],n,i,k,mid,s,e,f=0;
 clrscr();
 printf("\n Enter how many number u want:-");
 scanf("%d",&n);
 printf("\n Please enter %d sorted numbers:-",n);
 for(i=0;i<n;i++)
 {
  scanf("%d",&a[i]);
 }
 printf("\n numbers are:-");
 for(i=0;i<n;i++)
 {
  printf("\t%d",a[i]);
 }
 printf("\n\n Enter search key number:-\n");
 scanf("%d",&k);
 s=0;
 e=n-1;
 while(s<=e)
 {
  mid=(s+e)/2;
  if(k==a[mid])
  {
   printf("\n %d number is found on %d position.",k,mid+1);
   f=1;
   break;
  }
  else
  {
   if(k>a[mid])
   {
    s=mid+1;
   }
   else
   {
    e=mid-1;
   }
  }
 }
 if(f==0)
 {
  printf("\n number is not found");
 }
 getch();
}



/* OUTPUT
 Enter how many number u want:-5                                              
                                                                               
 Please enter 5 sorted numbers:-10 11 12 13 14                                
                                                                               
 numbers are:-  10      11      12      13      14                            
                                                                               
 Enter search key number:-                                                    
 12                                                                            
                                                                               
 12 number is found on 3 position.   */

C program for linear searching

#include<stdio.h>
#include<conio.h>
void main()
{
 int a[10],n,i,k,f=0;
 clrscr();
 printf("\n Enter how many number u want:-");
 scanf("%d",&n);
 printf("\n Enter %d numbers:-",n);
 for(i=0;i<n;i++)
 {
  scanf(" %d",&a[i]);
 }
 printf("\n numbers are:-\n");
 for(i=0;i<n;i++)
 {
  printf("\t%d",a[i]);
 }
 printf("\n Enter search key number:-");
 scanf("%d",&k);
 for(i=0;i<n;i++)
 {
  if(k==a[i])
  {
   printf("\n %d number is found on %d position.",k,i+1);
   f=1;
   break;
  }
 }
 if(f==0)
 {
  printf("\n Number is not found");
 }
 getch();
}
/*
 Enter how many number u want:-5                                              
                                                                               
 Enter 5 numbers:-4 6 8 9 14                                                  
                                                                               
 numbers are:-                                                                
        4       6       8       9       14                                    
 Enter search key number:-9                                                    
                                                                               
 9 number is found on 4 position.      */

C program in data structure to make circular linked list

#include<stdio.h>
#include<conio.h>
#include<process.h>
void create();
void display();
void addbeg();
void addlast();
struct node
{
 int info;
 struct node *link;
}*start=NULL;
void main()
{
 int n;
 clrscr();
 while(1)
 {
  printf("\n **menu**\n");
  printf("\n 1. to create list \n 2. to display list");
  printf("\n 3. to add node at beginning of linked list");
  printf("\n 4. to add node at the last of linked list");
  printf("\n 5. exit");
  printf("\n Enter your choice:-");
  scanf("%d",&n);
  switch(n)
  {
   case 1 : create();
   break;
   case 2 : display();
   break;
   case 3 : addbeg();
   break;
   case 4 : addlast();
   break;
   case 5 : exit(0);

  }
 }
 getch();
}

void create()
{
 struct node *temp,*q;
 int x;
 temp=(struct node *)malloc(sizeof(struct node));
 if(temp==NULL)
 {
  printf("\n Insufficient memory");
 }
 else
 {
  printf("\n Enter number:-");
  scanf("%d",&x);
  temp->info=x;
  temp->link=NULL;
  if(start==NULL)
  {
   start=temp;
  }
  else
  {
   q=start;
   while(q->link!=start)
   {
    q=q->link;
   }
   q->link=temp;
  }
  temp->link=start;
 }
}

void display()
{
  struct node *q;
  printf("\n Circular linked list is:-\n\n");
  q=start;
  while(q->link!=start)
  {
   printf("   %d",q->info);
   q=q->link;
  }
  printf("   %d",q->info);
}

void addbeg()
{
 int x;
 struct node *temp,*q;
 temp=(struct node*)malloc(sizeof(struct node));
 if(temp==NULL)
 {
  printf("\n Insufficient memory");
 }
 else
 {
  printf("\n Enter number:-");
  scanf("%d",&x);
  temp->info=x;
  temp->link=NULL;

  q=start;
  while(q->link!=start)
  {
   q=q->link;
  }
  temp->link=start;
  start=temp;
  q->link=start;
 }
}
void addlast()
{
 struct node *temp,*q;
 int x;
 temp=(struct node*)malloc(sizeof(struct node));
 if(temp==NULL)
 {
  printf("\n Insufficient memory");
 }
 else
 {
  printf("\n Enter number:-");
  scanf("%d",&x);
  temp->info=x;
  temp->link=NULL;

  q=start;
  while(q->link!=start)
  {
   q=q->link;
  }
  q->link=temp;
  temp->link=start;
 }
}

C program in data structure to find the intersection between two linked list

#include<stdio.h>
#include<conio.h>
#include<process.h>
#include<stdlib.h>
struct node
{
 int info;
 struct node *link;
}*start1=NULL,*start2=NULL;
void main()
{
 struct node *temp,*q,*p;
 int n,i,x,f=0;
 clrscr();
 printf("\n First linked list");
 printf("\n Enter How many number:-");
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
  temp=(struct node*)malloc(sizeof(struct node));
  if(temp==NULL)
  {
   printf("\n Insufficient memory");
   getch();
   exit(0);
  }
  printf("\n Enter number:-");
  scanf("%d",&x);
  temp->info=x;
  temp->link=NULL;
  if(start1==NULL)
  {
   start1=temp;
  }
  else
  {
   q=start1;
   while(q->link!=NULL)
   {
     q=q->link;
   }
   q->link=temp;
  }
 }
 printf("\n first list\n");
 q=start1;
 while(q!=NULL)
 {
  printf("\t%d",q->info);
  q=q->link;
 }
 start2=NULL;
 printf("\n Second linked list");
 printf("\n Enter How many number:-");
 scanf("%d",&n);
 for(i=0;i<n;i++)
 {
  temp=(struct node*)malloc(sizeof(struct node));
  if(temp==NULL)
  {
   printf("\n Insufficient memory");
   getch();
   exit(0);
  }
  printf("\n Enter number:-");
  scanf("%d",&x);
  temp->info=x;
  temp->link=NULL;
  if(start2==NULL)
  {
   start2=temp;
  }
  else
  {
   q=start2;
   while(q->link!=NULL)
   {
     q=q->link;
   }
   q->link=temp;
  }
 }
 printf("\n second list\n");
 q=start2;
 while(q!=NULL)
 {
  printf("\t%d",q->info);
  q=q->link;
 }
 printf("\n intersection of two list is:-\n");
 q=start1;
 while(q!=NULL)
 {
  p=start2;
  while(p!=NULL)
  {
   if(q->info==p->info)
   {
    printf("\t%d",q->info);
   }
   p=p->link;
  }
  q=q->link;
 }
 getch();
}

/*   OUTPUT
 First linked list                                                            
 Enter How many number:-5                                                      
                                                                               
 Enter number:-1                                                              
                                                                               
 Enter number:-2                                                              
                                                                               
 Enter number:-3                                                              
                                                                               
 Enter number:-4                                                              
                                                                               
 Enter number:-5                                                              
                                                                               
 first list                                                                    
        1       2       3       4       5                                      
 Second linked list                                                            
 Enter How many number:-4

 Enter number:-1

 Enter number:-2

 Enter number:-5

 Enter number:-6

 second list
1       2       5       6
 intersection of two list is:-
1       2       5            
*/

List of bank names in India

 Here is a comprehensive list of banks in India, categorized by type: