Thursday, 26 January 2012

Write a C program to print all Combinations of characters A, B, C

#include<stdio.h>
#include<conio.h>
void main()
{
    char ch1, ch2, ch3;
    clrscr();
    for(ch1='A' ; ch1<='C' ; ++ch1)
    {
        for(ch2='A' ; ch2<='C' ; ++ch2)
        for(ch3='A' ; ch3<='C' ; ++ch3)
        printf("%c%c%c\t", ch1, ch2, ch3);
    }
    getch();
}


Output:-
AAA AAB AAC ABA ABB ABC ACA ACB ACC
BAA BAB BAC BBA BBB BBC BCA BCB BCC
CAA CAB CAC CBA CBB CBC CCA CCB CCC

No comments:

Post a Comment