Answer to Question #264984 in C for Jack

Question #264984

A toy company manufactures electronic learning boards for kids to learn alphabets. Accordingly,





when a kid presses 1 alphabet a is shown on the screen, and when 2 is pressed ab is shown along





with the previous alphabet and so on. The patterns are likely to be as follow:







a





ab





abc





abcd





abcde





:





:





:





:





abcdefghijklmnopqrstuvwxyz





Develop a C-script which generates the above-mentioned pattern


Note: Don't use array , do with loops

1
Expert's answer
2021-11-13T12:41:00-0500

Source code



#include <stdio.h>


int main()
{
    char alphabet[26]="abcdefghijklmnopqrstuvwxyz";
    int n;
    printf("\nEnter a number: ");
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        for(int j=0;j<=i;j++){
            printf("%c",alphabet[j]);
        }
        printf("\n");
    }


    return 0;
}

Output





Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS