Thank you all for being with us.
Learn, Create and Implement.

  • Build Concept

    You can build your concept in programming on programsway.com.

  • Examples

    There are many C Programming examples on programsway.com.

  • Ask Questions

    Ask questions and get quick answers. Request any program and we will publish that program.

  • Wednesday, 20 March 2013

    In Data Structures the program infix to post fix using stack is very important. There for here is an example for  this program. Here we use a stack named stack to store in-stack elements.
    /* This is a program to turn a infix expression into post-fix expression and then evaluate the expression */
    #include<stdio.h>
    #include<stdlib.h>
    #include<string.h>
    #include<ctype.h>

    void push(char);
    char pop();
    int prt(char);
    int eval(char *);


    int top=-1;
    char stack[30];

    main()
    {
      int i=0,k=0;
      char infix[30],postfix[30];
      printf("Enter the expression ");
      scanf("%s",infix);
      for(i=0;i<strlen(infix);i++)
        {
        if(isdigit(infix[i]))
        postfix[k++]=infix[i];
        else if(top==-1||prt(infix[i])>prt(stack[top]))
    {
    postfix[k++]=' ';
    push(infix[i]);
    }
    else
    {
         while(prt(infix[i])<=prt(stack[top])&&top>-1)
    postfix[k++]=pop();
         push(infix[i]);
         }
    }
    while(top>-1)
    postfix[k++]=pop();
         postfix[k]='\0';
    printf("The postfix expression is %s\n",postfix);
    printf("The result is %d\n",eval(postfix));
    }

    void push(char a)
    {
    stack[++top]=a;
    return;
    }

    char pop()
    {
    return stack[top--];
    }

    int prt(char a)
    {
    if(a=='+'||a=='-') return 1;
    else if(a=='*'||a=='/') return 2;
    }

    int eval(char *str)
    {
      int a[30],i,n=-1,j=0;
      char temp[5];
      for(i=0;str[i]!='\0';i++)
      {
        if(isdigit(str[i]))
    temp[j++]=str[i];
        else if(str[i]==' ')
    {
    temp[j]='\0';
    a[++n]=atoi(temp);
    j=0;
    }
    else
    {
    if(j!=0)
    {
    temp[j]='\0';
    a[++n]=atoi(temp);
    j=0;
    }
    if(str[i]=='+')
    a[n-1]=a[n-1]+a[n];
    else if(str[i]=='-')
    a[n-1]=a[n-1]-a[n];
    else if(str[i]=='*')
    a[n-1]=a[n-1]*a[n];
    else if(str[i]=='/')
    a[n-1]=a[n-1]/a[n];
    n--;
    }
      }
      return a[0];
    }

    The output of this program......









    Sunday, 10 March 2013


    This is a program show the applications the mod (%) operation.

    /*This is a program to input three digit number from user and display square of first and last number */
    #include<stdio.h>
    int main()
    {
    int num,rem,sqr1,sqr2;
    start:
    printf("Enter a three digit number  ");
    scanf("%d",&num);
    if(num>999){
    printf("\nSorry you have Entered long number\n");
    goto start;
    }
    if(num<100){
    printf("\nSorry you have entered short number\n");
    goto start;
    }
    rem=num%10;
    sqr2=rem*rem;
    num=num/10;
    num=num/10;
    sqr1=num*num;
    printf("\nThe square of the first digit is %d and the square of the last digit is %d \n",sqr1,sqr2);
    return 0;
    }

    The output of this program ....

    Saturday, 9 March 2013

    In C every character has a ASCII number. Here we can use this concept for this program.
    First we take a input from user. Then we check whether it is an alphabet or not and also check whether it is  in capital or in small letter. If it is in capital then we add 32 with the character's ASCII value.
    If it is in small letter then we subtract  32 from the character's ASCII value.
                                              For your convenience here is the ASCII chart.

    Now the the example ....


    #include<stdio.h>
    #include<ctype.h>
    int main()
    {
    char c;
    printf("Enter a  alphabet  ");
    scanf("%c",&c);
            if(isalpha(c))
            {
             if(c<'a')
               {
          c+=32;
          printf("\nYou have entered capital letter\nThe corresponding  small letter is  %c\n",c);
               }
            else
               {
                  c-=32;
                  printf("\nYou have entered small letter\nThe corresponding  capital letter is  %c\n",c);
                }
            }
    return 0;
    }

    The output of this program will be....

    Friday, 8 March 2013

    We can inter change values with out using third variable.


    //This is a program to interchange values of to number without using third variable

    #include<stdio.h>
    int main()
    {
    int a,b;
    printf("Enter the frist number ");
    scanf("%d",&a);
    printf("\nEnter the scond number ");
    scanf("%d",&b);
    a=a*b;
    b=a/b;
    a=a/b;
    printf("\nThe interchanged values are\nThe frist number is %d\nThe scond number is %d\n",a,b);
    return 0;
    }

    The output will be.....

    This is a simple program to swap the values using third variable.


    //This is a program to interchange vaules of to number using thrid variable
    #include<stdio.h>
    int main()
    {
    int fst_num,snd_num,trd_num;
    printf("Enter the frist number ");
    scanf("%d",&fst_num);
    printf("\nEnter the scond number ");
    scanf("%d",&snd_num);
    trd_num=fst_num;
    fst_num=snd_num;
    snd_num=trd_num;
    printf("\nThe interchanged values are\nThe frist number is %d\nThe scond number is %d\n",fst_num,snd_num);
    return 0;
    }

    The output of this program will be.....



    This is a c program to find out the area of a circle.


    #include<stdio.h>
    #define PI 3.14
    int main()
    {
    int redius;
    float area;
    printf("Enter the redius of the circle ");
    scanf("%d",&redius);
    area=PI*redius*redius;
    printf("\nThe area of the circle is %5.2f\n",area);
    return 0;
    }


    The out put will be....

    This is a example of simple program to find out the square and cube of a number.
    This program can be extended to find out any power of a number using recursion function.

    //This is a program to find out Square and Cube of a given number
    #include<stdio.h>
    int main()
    {
    int num,sqrt,cube;
    printf("\nEnter a number to Square and Cube ");
    scanf("%d",&num);
    sqrt=num*num;
    cube=num*num*num;
    printf("\nThe Square of the give number is %d\nand the cube of the give number is %d",sqrt,cube);
    return 0;
    }