NAV BAR

Thursday 11 August 2016

How to prevent ban in pokemon go

Awesome  how to prevent getting bans in pokemon go
Please go here

http://adf.ly/1d4Nfal

Monday 8 August 2016

Infix to postfix expression in C


#include<stdio.h>
#include<ctype.h>
#include<string.h>
#define MAX 10
/*Working fine no issues*/
char stack[MAX];
int top = -1;
void push(char);
char pop();
void Infixtopostfix(char [],char[]);
int priority(char);
void main()
{
    char infix[20],postfix[20];
    printf("Enter infix  expression");
    scanf("%s",infix);
    Infixtopostfix(infix,postfix);
    printf("postfix exp = %s",postfix);
    getch();
}
void Infixtopostfix(char infix[],char postfix[])
{
     int i,j=0;
    char temp;
    for(i=0;infix[i]!='\0';i++)
    {
        if(infix[i]=='(')
            push(infix[i]);
        else if(isdigit(infix[i])||isalpha(infix[i]))
        {
            postfix[j]=infix[i];
            j++;
        }
        else if(infix[i]==')')
        {
            if(top==-1)
            {
                printf("Incorrect expression");
                exit(1);
            }
            while((top!=-1)&&(stack[top]!='('))
            {
                postfix[j]=pop();
                j++;
            }
            temp = pop();
        }
        else if(infix[i]=='+'||infix[i]=='-'||infix[i]=='/'||infix[i]=='*')
        {
            while((top!=-1)&&(stack[top]!='(')&&(priority(stack[top]>=priority(infix[i]))))
            {
                postfix[j]=pop();
                j++;
            }
            push(infix[i]);
        }
        else
        {
            printf("Incorrect expression");
            exit(1);
        }
    }
    while(top!=-1)
    {
        postfix[j]=pop();
        j++;
    }
    postfix[j]='\0';
}
void push(char ch)
{
    top++;
    stack[top]=ch;
}
char pop()
{
    char val;
    val = stack[top];
    top = top-1;
    return val;
}
int priority(char ch)
{
    if(ch=='*'||ch=='/')
        return 1;
    if(ch=='+'||ch=='-')
        return 0;
}

To find Smallest number in C

#include<stdio.h>
#include<conio.h>
void main()
{
    int i,n,a[100],small;
    printf("Enter number of element");
    scanf("%d",&n);
    printf("Enter value of each element");
    for(i=0;i<n;i++)
    {
       scanf("%d",&a[i]);
    }

    small = a[0];
    for(i=1;i<n;i++)
    {
        if(a[i]<small)
        {
            small = a[i];
        }
    }
    printf("Smallest element is %d",small);
    getch();
}

To find Second largest number in C

#include<stdio.h>
#include<conio.h>
void main()
{
    int large,largesec,n,a[100],i;
    printf("Enter number of element");
    scanf("%d",&n);
    printf("Enter value of each element");
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    large = a[0];
    for(i=1;i<n;i++)
    {
        if(a[i]>large)
        {
            large = a[i];
        }
    }
    printf("Large is %d\n",large);

    largesec = a[0];

    for(i=0;i<n;i++)
    {
        if(a[i]!=large)
        {
            if(largesec < a[i])
            {
                largesec = a[i];
            }
        }
    }
    printf("Second Largest no is %d",largesec);
    getch();
}

To Reverse a Stack in C

#include<stdio.h>
#include<conio.h>
#define MAX 10
int top=-1;
int stack[MAX];
void main()
{
    int a[10],i,n,val;
    printf("Enter number of value\n");
    scanf("%d",&n);
    printf("Enter value of each element\n");
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        push(a[i]);
    }
    for(i=0;i<n;i++)
    {
        val = pop();
        a[i] = val;

    }
    for(i=0;i<n;i++)
    {
        printf("%d\n",a[i]);
    }
}
void push(int val)
{
    stack[++top] = val;
}
int pop()
{
    int temp;
    temp = stack[top--];
    return temp;
}

To print Triangle

#include<stdio.h>
int main()
{
    int n,a,b,c,d,i,j;
    b=-1;
    printf("Enter value of n\n");
    scanf("%d",&n);
    c=0;
    a=0;
   for(i=1;i<=n;i++)
   {
       for(j=n-i;j>0;j--)
       {
           printf(" ");
       }
       for(j=1;j<=i;j++)
       {

        a = c+22+16*b;
        printf("%05d\t",(a));

        c=a;
        b++;
    }
    printf("\n");
   }
   return 0;

}


Output 
 0028
0066   00.......

Radix Sort In C

#include<stdio.h>
#include<conio.h>
void main()
{
    int a[100],n,i;
    printf("Enter number of elements\n");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    radix(a,n);
    getch();
}
void radix(int a[],int n)
{
    int i,j,k,temp,buck[10][20],div=1,r,pass,count[10];
    int max = largest(a,n);
    for(pass=1;pass<=max;pass++)
    {
        for(i=0;i<10;i++)
        {
            count[i]=0;
        }
        for(i=0;i<n;i++)
        {
            r = (a[i]/div)%10;
            buck[r][count[r]] = a[i];
            count[r]++;
        }
    }
}

Sum of Consecutive Prime Numbers

#include<stdio.h>

int main()
{
    int j,i,flag,N,temp,sum,prime =0,flag1,m,n;
    printf("Till how many prime number do you need output\n");
    scanf("%d",&N);

    for(i=2;i<=N;i++)
    {
        flag = 0;

        for(j=2;j<i;j++)
        {
            if(i%j==0)
            {
                flag = 1;
                break;
            }
        }
        if(flag==0&&i!=2)

             {

                 sum =0;
                 temp = i;
                 for(m=2;m<=N;m++)
                 {
                     flag1 = 0;

                     for(n=2;m<n;m++)
                     {
                         if(m%n==0)
                         {
                             flag1=1;
                             break;
                         }
                     }
                     if(flag1==0)
                     {
                         sum = sum +m;
                         if(sum==temp)
                         {
                             prime++;
                             sum=0;

                         }

                     }
                 }


             }


    }
    printf("%d",prime);
    return 0;
}

Infix to Postfix Evaluation

#include<stdio.h>
#include<ctype.h>
#include<String.h>
#define MAX 100
char stack[MAX];
int top =-1;
void push(char);
char pop();
int priority(char);
void InfixPostfix(char [],char[]);
void main()
{
    char infix[20],postfix[20];
    printf("Enter a infix expression\n");
    scanf("%s",infix);
    InfixPostfix(infix,postfix);
    printf("Postfix is  %s",postfix);
    getch();
}
void InfixPostfix(char infix[],char postfix[])
{
    int i,j=0;
    char temp;
    for(i=0;infix[i]!='\0';i++)
    {
        if(infix[i]=='(')
        {
            push(infix[i]);
        }
        else if(isdigit(infix[i])||isalpha(infix[i]))
        {
            postfix[j] = infix[i];
            j++;
        }
        else if(infix[i]==')')
        {
            if(top==-1)
            {
                printf("Invalid Expression");
                exit(1);
            }
            while((top!=-1)&&(stack[top]!='('))
            {
                postfix[j]=pop();
                j++;
            }
            temp=pop();
        }
        else if(infix[i]=='+'||infix[i]=='-'||infix[i]=='*'||infix[i]=='/')
        {
            while((top!=-1)&&(stack[top]!='(')&&(priority(stack[top]>=priority(infix[i]))))
            {
                postfix[j]=pop();
                j++;
            }
            push(infix[i]);
        }
        else
        {
            printf("Incorrect expression\n");
            exit(1);
        }
    }
    while(top!=-1)
    {
        postfix[j]=pop();
        j++;
    }
    postfix[j]='\0';
}
void push(char ch)
{
    top++;
    stack[top]=ch;
}
char pop()
{
    char val;
    val = stack[top];
    top--;
    return val;
}
int priority(char ch)
{
    if(ch=='*'||ch=='/')
        return 1;
    if(ch=='+'||ch=='-')
        return 0;
}

Working With normal Stack in C

/*All operation in stack are performed in top order
For a stack top element has most priority*/
/*It is last in first out */
/*when you press back button in browser then this is what we call it as stack*/
/*PUSH is for insert
POP is for delete
PEEK is to display*/
/*There is one error when i enter 1 or 0 for repeat it simply goes to end *******************************************ERROR***********   */
#include<stdio.h>
#include<conio.h>
#define MAX 5
int top,num,temp,stack[];
void push();
void pop();
void peek();
void status();
void main()
{
    int choice,n,num,temp;
    int rpt=1;
    int stack[MAX];
    top = -1;
    printf("Enter your choice from given below\n");
    do
    {
        printf("1.Push\n2.Pop\n3.Peek\n4.Current status\n");
        scanf("%d",&choice);
        switch(choice)
        {
            case 1:push();
                   break;
            case 2:pop();
                   break;
            case 3:peek();
                   break;
            //case 4:status();
                 //  break;
        }
        printf("do you wish to continue?(Type Y or N)\n");
        scanf("%c",&rpt);
    }
    while(rpt==1);//||rpt=='y');
    getch();
}
void push()
{
    if (top==MAX-1)
    {
        printf("Sorry! Stack is full");
    }
    else
    {
        printf("Enter a number to be inserted\n");
        scanf("%d",&num);
        stack[top++]=num;
        printf("Number %d has been inserted\n",num);
    }
}
void pop()
{
    if(top==-1)
    {
        printf("Stack is empty\n");
    }
    else
    {
        temp = stack[top];
        printf("your number has %d has been removed\n",temp);
    }
}
void peek()
{
    if(top==-1)
    {
        printf("Stack is empty\n");
    }
    else
    {
        printf("Your top most element is %d\n",stack[top]);
    }
}