Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

WAP to display the following pattern:

+1 vote
asked Oct 22, 2019 by VISHAL GAUR (130 points)
AAAA

AAAB

AAAC

...

...

AAAZ

AABA

AABB

...

AABZ

7 Answers

0 votes
answered Oct 25, 2019 by gameforcer (2,990 points)
edited Oct 25, 2019 by gameforcer

At least you should state in what language you want to have it written.

@edit

If you need a program in C as in answers below then the easiest way is:

#include <stdio.h>

int main()
{
    for(char a = 'A'; a <= 'Z'; a++)
        for(char b = 'A'; b <= 'Z'; b++)
            for(char c = 'A'; c <= 'Z'; c++)
                for(char d = 'A'; d <= 'Z'; d++)
                    printf("%c%c%c%c\n", a, b, c, d);
    return 0;
}

 

0 votes
answered Oct 25, 2019 by rohan ag (1,310 points)
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby,
C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS
Code, Compile, Run and Debug online from anywhere in world.

AAAA

AAAB

AAAC

...

...

AAAZ

AABA

AABB

...

AABZ

*******************************************************************************/
#include <stdio.h>

int main()
{
char ch='A';
int i,j,c=0;

while(c<2)
{

   for(i=0;i<26;i++)
   {
       for(j=0;j<4;j++)
         
                     {
                                 if(c==0)
                                 {
                                                 if(j!=3)
                                                    printf("%c",ch);
                                                 else
                                                    printf("%c",ch+i);
                                           
                                             
                                                   
                                  }
                                               
                     
                     
                                     
                     
                                 else  
                                 
                                 {
                                 
                                 
                                              if(j==2)
                                               printf("%c",ch+c);
                                             
                                                else if(j==3)
                                                    printf("%c",ch+i);
                                                 else
                                                    printf("%c",ch);
                                           
                                             
                                           
                                 }
                                 
               }
               printf("\n");
         
                
      }
      c++;
      
}
    return 0;
}

if you have queries then even i will also attach the link([email protected])
+1 vote
answered Oct 25, 2019 by rohan ag (1,310 points)
0 votes
answered Oct 25, 2019 by anonymous
#in python

for i in range(2):
    for j in range(26):
        s=65+j
        print("AA"+chr(65+i)+chr(s))
0 votes
answered Oct 26, 2019 by paawantripathy1 (140 points)
#include<iostream>
#include<string.h>
using namespace std ;
int main ()
{
    int n;
    cout<<"enter size";
    cin>>n;
    char a[n];
    cout<<"enter the starting pattern";
    cin>>a;
    for(int i=0;i<26;i++)
    {
         cout<<"\n"<<a;

        a[strlen(a)-1]=a[strlen(a)-1]+1;

    }
    a[strlen(a)-2]=a[strlen(a)-2]+1;
    a[strlen(a)-1]='A';
    for(int j=0;j<26;j++)
    {
        cout<<"\n"<<a;
        a[strlen(a)-1]=a[strlen(a)-1]+1;

    }

}
0 votes
answered Oct 26, 2019 by anonymous
public class Main

{

public static void main(String[] args) {

    String sample = "AAA";

    String sample2 = "AAB";

    String ar[] = new String[26];

    display(ar,sample);

    display(ar,sample2);

}

static void display(String ar[], String sample){

        for(int i = 65; i<91;i++){

            sample+=(char)i;

            System.out.println(sample);

            sample = sample.substring(0,3);

        }     

}

}
0 votes
answered Oct 26, 2019 by anonymous
public class Main

{

public static void main(String[] args) {

    String sample = "AAA";

    String sample2 = "AAB";

    display(sample);

    display(sample2);

}

static void display(String sample){

        for(int i = 65; i<91;i++){

            sample+=(char)i;

            System.out.println(sample);

            sample = sample.substring(0,3);

        }     

}

}
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...