Pages

Wednesday, 7 November 2012

WAP to print the possible combination of a Three Letter Word.

  • WAP to print the possible combination of a Three  Letter Word.
               INPUT:        TOP
               OUTPUT:    TOP
                                  TPO
                                  OTP
                                  OPT
                                  PTO
                                  POT                             
#include <stdio.h>
void main()
{
    int i,j,k;
    char str[10];
    printf("Enter a three letter word");
    scanf("%s",&str);
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            for(k=0;k<3;k++)
            {
            if((i!=j)&&(j!=k)&&(k!=i))
            printf("%c%c%c\n",str[i],str[j],str[k]);
            }
        }
    }
    }

No comments:

Post a Comment