Time remaining:
C Program help: Barber Pole

Programming
Tutor: None Selected Time limit: 0 Hours

Prompt:

Write a barber pole program. The program will prompt for a character string of up to 10 characters. The program will then print 10 lines. After each line, the string is rotated to start at the next character. The result will look like a barber pole.

Modify the program to print the barber pole followed by 10 lines where the barber pole is printed in reverse character order.

My code:

#include <stdio.h>

#include <string.h>

main(){

    char BarbPole[10];

    int i,j,k;

    printf("\nPlease enter a string: ");

    scanf("%s",BarbPole);

    for(i=0;i<strlen(BarbPole);i++){

        printf("\n");

        for(j=i+1;j<strlen(BarbPole);j++)

            printf("%c",BarbPole[j]);

        for(k=0;k<=i;k++)

            printf("%c",BarbPole[k]);

       

        printf("\n The reversal is:");

        for(k=strlen(BarbPole)-1;k>=0;k--)

            printf("%c",BarbPole[k]);

    }

    getchar();

}

Output:

Please enter a string: 432

324

 The reversal is:234

243

 The reversal is:234

432

 The reversal is:234


What I need it to output:

432

324

243

Reversal:

342

423

234

Nov 30th, -0001
hi i can help you .i am a software engineer and i did such work before
Jul 14th, 2013

Really? yay :) ok not sure how this site works.. 

Jul 14th, 2013

me also i am new here.dnt exactly know but i can help to answer this

Jul 14th, 2013

ok then do you know what I am doing wrong? I swear I can't seem to figure it out!

Jul 14th, 2013

i can't tell it now. make a deal and i will answer it then

Jul 14th, 2013

Did you know? You can earn $20 for every friend you invite to Studypool!
Click here to
Refer a Friend
...
Nov 30th, -0001
...
Nov 30th, -0001
Dec 9th, 2016
check_circle
Mark as Final Answer
check_circle
Unmark as Final Answer
check_circle
Final Answer

Secure Information

Content will be erased after question is completed.

check_circle
Final Answer