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.

  • Monday, 12 August 2013

    Written by Kousik : 
    Every programming language has a grammar. Different programming language has different grammar. So to learn C programming language we have to be familiar with that grammar which is related to C program. The grammar is nothing but CONSTANTS, VARIABLES, & their DATA TYPES.
    CONSTANTS:
    There are two types of C constants. One is PRIMARY and other is SECONDARY.
    Primary constants are of three types.
    1)      Integer Constant
    2)      Real Constant
    3)      Character Constant
    Secondary constants are of several types.
    1)      Array
    2)      Pointer
    3)      Structure
    4)      Union
    5)      Enum etc…
    Now we have to primary constants first…
    Integer Constants:
    Characteristics: a) An integer constants must have at least one digit. It must not have a decimal point.
                                    b) It can either positive or negative. If no sign proceeds then the integer assumed to be positive.
                                    c) The range for integer constants is -2147483648 to +2147483647. The range of integer constants is depend upon the compiler (visual studio, gcc  , turbo c etc).
    Example : 400, -421,+755 etc
    Real Constants (Floating Point Constants) :
    Real constants can be shown in two forms. One is fractional form and other is exponential form.
    Characteristics   of Fractional form  :
    a)      A real constants must have at least one digit . It must have a decimal point.
    b)      It can be either positive or negative. If no sign proceeds then the integer assumed to be positive.
    c)       No blanks are allowed within a real constant.
    Example  : -69.35 , 12.00 , +39.355 etc
    In exponential form the real is represented in two major parts  . The part coming before ‘e’ is called ‘mantissa’ and the part coming after ‘e’ called ‘exponent’ .
    Characteristics of exponential form:
    a)      The word ‘e’ separate the exponential part and the mantissa part of real constants.
    b)      The mantissa part may have +ve or –ve sign. . If no sign proceeds then the integer assumed to be positive.
    c)       The exponent must have at least one digit.
    d)      Range = -3.4e38 to +3.4e38
    Example: 3.2e-23, -0.45e+33 etc
    Character Constants:
    Characteristics
    a)      A character constant can be a single alphabet, single digit or a single special symbol enclosed with single inverted commas.
    b)      The maximum length of a character constant is 1 character.
    Example: ‘A’, ‘c’, ‘5’, ‘/’ etc
    *Secondary constants will be discussed later.
    VARIABLE:
    To store the data value in computer memory we have to know about VARIABLES.  Variables names are names given to location in memory. These locations can contain Integer, real, character constants .Type of variables are depending upon the type of constants. For example an integer type of variable can holds only the integer constants. The variable name is chosen by the programmer in such a way that shows its nature in the program.
    Example:  class, roll, count etc
    Characteristics of variables:
    a)      They must begin with a letter.
    b)      A variable name is any combination of 1 to 31 alphabets, digits or underscores. The length of variables is depending upon the compiler.
    c)       No special symbol other than an underscore can be used in a variable name.
    d)      Uppercase and lowercase are very significant.

    C KEYWORDS:
    C compiler has some words whose meaning has already been explained. There are 32 keywords available in C. Different keywords have different meaning.
     auto                       double                     int                                        struct
     Break                     else                        long                                      switch
     case                       enum                      register                                typedef
     char                       extern                     return                                  union
     const                     float                        short                                 unsigned
     continue                 for                            signed                                  void
     default                  goto                         sizeof                                   volatile
     do                          if                           static                                    while
    To know more about c keywords you can follow LET UC C(by yashvant kanetkar) & ANSI C (by Balaguruswamy) .










                    `              




    Sunday, 28 July 2013

    Written by Saikat :

    DIVIDE AND CONQUER ALGORITHM:

    The most commonly used & convenient algorithm is the 'Divide & conquer' algorithm. If a problem is tough to solve, then we can assume that this problem is made up by some small problems. Then we can break the main problem in some small sub-problems. Now we can easily solve the sub-problems. By this we can solve the whole problem very easily. This method is called Divide and Conquer method. By this method we can also develop efficient programs to solve a particular problem. 

    STEPS INVOLVED IN THIS ALGORITHM: 

    1) Divide the total problem into several sub problems of equal length.
    2) Obtain the solution of the individual sub problems.
    3) Combine the solutions to get the main solution.

    ASPECT:

    The basic aspect of this algorithm is to minimize the time complexity of a given problem as much as possible. There may be various types of algorithms to solve a particular problem. Among   those we shall choose that one, which will take a polynomial order of time complexity, i.e. we will have to choose in such a way that it requires a least number of operations. It will be better if it takes time complexity of linear order.


    EXAMPLE:

               Take the example of the finding out the maximum and minimum from a set of integers. If we look the overall problem then we will face some challenges. So, just forget the whole problem. Now if there are two numbers then we can easily find out which is smaller and which is bigger by following algorithm.

    If(a>b)  then  MAX <- a and MIN <- b
    Else MAX <- b and MIN <- a

    This is an easy problem to solve. So, we assume this problem as a unit problem and break the whole problem into sub problems.

    Now look at the program and find out what we are doing in it.
    #include<stdio.h>
    #include<stdlib.h>

    int *a;

    typedef struct list
    {
      int min,max;
    }ln;

    ln minmax(int,int);
    int min(int,int);
    int max(int,int);

    main()
    {
      int i,n;
      ln ext;
      printf("Enter the number of element ");
      scanf("%d",&n);
      a=(int *)calloc(n,sizeof(int));
      printf("Enter the numbers ");
      for(i=0;i<n;i++)
      scanf("%d",(a+i));
      ext=minmax(0,n-1);
      printf("The minmum value is %d and the maximum value is %d",ext.min,ext.max);
      return;
    }

    ln minmax(int n1,int n2)
    {
      ln ext,ext1,ext2;
      if(n2-n1==1)
      {
        ext.min=min(a[n1],a[n2]);
    ext.max=max(a[n1],a[n2]);
    return ext;
      }
      else
      {
      ext1=minmax(n1,(n1+n2)/2);
      ext2=minmax((n1+n2)/2+1,n2);
      ext.min=min(ext1.min,ext2.min);
      ext.max=max(ext1.max,ext2.max);
      return ext;
      }
    }

    int max(int a, int b)
    {
      if(a>b)
      return a;
      else
      return b;
    }

    int min(int a, int b)
    {
      if(a<b)
      return a;
      else
      return b;
    }

    Thursday, 25 July 2013


    Posted by Kousik
    This is a program to calculate your age.
    /*AGE CALCULATE*/
    #include<stdio.h>
    int main()
    {
    int dd,dm,dy,cd,cm,cy,d,m,y;
    printf(“Enter your DATE OF BIRTH in dd mm yyyy format\n”);
    scanf(“%d %d %d”,&dd,&dm,&dy);
    printf(“Enter Current Date in dd mm yyyy format\n”);
    scanf(“%d %d %d”,&cd,&cm,&cy);
    y=cy-dy;
    if(dm>cm)
    {
    y--;
    m=12-(dm-cm);
    if(dd>cd)
    {
    m--;
    d=30-(dd-cd);
    }
    else
    {
    d=cd-dd;
    }
    }
    else
    {
    m=cm-dm;
    if(dd>cd)
    {
    m--;
    d=30-(dd-cd);
    }
    else
    {
    d=cd-dd;
    }
    printf(“You AGE is \n”);
    printf(“%d days %d months %d years\n”,d,m,y);
    }

    Friday, 17 May 2013


    This is a program to convert binary to decimal
    /* author- WYES KARNY */
    #include<stdio.h>
    int main()
    {
      int a,rem,des=0,i=1;
    printf("Enter a binary number ");
    scanf("%d",&a);
    while(1)
    {
    rem=a%10;
    a=a/10;
    des+=rem*i;
    i=i*2;
    if(a==0)
    break;
    }
    printf("\nThe equevalent desimal value is %d \n",des);
    return 0;
    }

    And for the Decimal to binary
    #include<stdio.h>
    int main()
    {
    int a,i,shift,bit;
    scanf("%d",&a);
    for(i=0;i<16;i++)
    {
    shift=a<<i;
    shift=shift>>15;
    bit=shift&1;
    if(bit==1)
    printf("1");
    else
    printf("0");
    }
    }

    Friday, 10 May 2013

    Linked List is collection of data which is linked together in a specific way.
    It is very efficient for computer memory. It consumes memory usage and save memory spaces.
    It works as Dynamic Allocation System (DMA).
    First we have to know -

    1. What is Linked List?
    2. Why we use Linked List?
    3. How do we implement Linked list?
    We will find answers for all of these questions.
    I have given some introduction of linked list above but did not define yet.
    Linked List is a list consisting element of structure type, which contains the data and link to the next element.
    The picture can clear your confusion.
    Here every block represents an element of the linked list. Every block contains two sub-blocks.
    One block is for the data, saved in the element and other for the link to the next element.

    Next question is, why we use it. Let us consider an example, in a school, there is a class consisting 50 students. If we save their marks in an array according to their roll numbers, then we have to declare an array of 50 elements. If we do this then when a new student gets admission, we have no space for the new student.
    If we declare an array of 100 elements at first then it would be possible but it wastes a huge memory space.
    Therefore in this case we can use Linked List.

    Next, implementation of linked list, 
    Here is a program to implement linked list.

    #include<stdio.h>
    #include<stdlib.h>
    typedef struct link_list
    {
      int number;
      struct link_list *next;
    }l;

    void create(l *list);
    void print_list(l* list);

    main()
    {
      l *head;
      head=(l*)malloc(sizeof(l));
      create(head);
      print_list(head);
    }



    void create(l *list)
    {
      char c;
      printf("Enter the number\n");
      scanf("%d",&list->number);
      printf("continue...  ");
      getchar();
      c=getchar();
      if(c=='y')
      {
      list->next=(l*)malloc(sizeof(l));
      create(list->next);
      }
      else
      list->next=NULL;
    }




    void print_list(l* list)
    {
      if(list->next!=NULL)
      {
      printf("%d  ",list->number);
      print_list(list->next);
      }
      else
      printf("%d\n",list->number);
    }


    (If you have any question, feel free to ask me)

      

    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 ....