C/C++ Program to Print Following Pattern

ABCDEFGFEDCBA
ABCDEF  FEDCBA
ABCDE     EDCBA
ABCD         DCBA
ABC             CBA
AB                 BA
A                     A

C Program

C++ Program

C/C++ Program to Print Following Pattern ABCDEFGFEDCBA ABCDEF  FEDCBA ABCDE     EDCBA ABCD         DCBA ABC             CBA AB                 BA A                     A

Comment below if you find any difficulty in understanding the above programs.

9 thoughts on “C/C++ Program to Print Following Pattern

  1. R.Hari Krishnan

    We can use two loops for much easier executions….
    #include
    main ()
    {
    Int n,i,j,k;
    printf(“Enter the num/n”);
    scanf(“%d”,&n);
    for(i=0;i<=n,i++)
    for(j=-n;j<=n,j++)
    {
    k=j;
    if(k=i)
    printf(“%c”,ch-k);
    else
    printf(” “);
    }
    printf(“/n”);
    }

    Reply
  2. Manan Sharma

    #include
    #include

    int main()
    {
    int i,j,k;
    int space;
    int limit=71;

    for(i=0;i<=6;i++)
    {
    for(k=65;k<=limit;k++)
    printf("%c",k);
    space=i*2-1;
    for(j=1;j=65;k–)
    {
    if(k<=70)
    printf("%c",k);
    }
    printf("\n");
    limit–;
    }
    return 0;
    }

    Reply
  3. suvasish

    what if i want the output as
    A
    BA
    CBA
    DCBA
    EDCBA what to do then? (code in c++ please)

    Reply
    1. Sreelekha

      #include
      using namespace std;
      int main()
      {
      char alpha;
      for(char ref=’A’; ref=’A’; alpha–)
      {
      cout<<alpha;
      }
      cout<<endl;
      }
      return 0;
      }

      Reply
    2. krishan kant

      write a code for following out put
      ACB
      CED
      EGF
      GIH
      IKJ

      Reply
  4. Anish Memon

    what if I want the output as:-
    A B C D E F G
    A B C E F G
    A B F G
    A G

    Reply
  5. Pratham Chaudhary

    import java.util.Scanner;
    public class Main
    {
    public static void main(String[] args) {
    System.out.println(“Hello World”);
    char arr[] = new char[27];
    Scanner sc = new Scanner(System.in);
    char Char = sc.next().charAt(0);
    // int no = sc.nextInt();
    int z = (int)Char;
    int f = z;
    int l = 2*(z-65);
    System.out.println(z+” “);
    for(int k =0 ;k<=(z-65);k++){
    for(int i=65;i<= f;i++)
    {
    if(i0){
    for(int m =(2*k);m>0; m–){
    System.out.print(” “);
    } }
    }

    if(i>=f){

    if(k==0){for(int j=(f-k-1);j>64;j–){
    char y = (char)(j);
    System.out.print(y+” “);
    }}
    else{

    if(k>=2){
    for(int m = 2*(k-1);m>0; m–)
    {
    System.out.print(” “);
    }
    }
    for(int j=(f-k);j>64;j–){
    char y = (char)(j);
    System.out.print(y+” “);
    }
    }
    }

    }
    System.out.println(” “);

    }

    }
    }

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *