Solve a repet probleme

0 Fayazur Rahman Summit · April 20, 2015

Write a single loop to print the following: (In each pass you should print only one number):

aaabbbcccZaaabbbcccXaaabbbcccVaaabb

Post a Reply

Replies

Oldest  Newest  Rating
0 Fayazur Rahman Summit · April 20, 2015
i already finish till this situation 

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i;
    for(i=0; i<=31; i++){
        printf("%c", (i/3)%3+'a');
    }

    return 0;
}


but i cant print 'Z'   'X'   'V'   between the cycle
 
help me by programming language C
0 Dol Lod · April 20, 2015
I think you could easily solve this problem by using the modulus operator. 

Check if i is 10,20, and 30 respectively and print out the corresponding characters. 

If you couldn't just do it this way, provide more of the specifications. 
0 Fayazur Rahman Summit · April 21, 2015
wao

this program is solved


#include <stdio.h>
#include <stdlib.h>

int main()
{
    int i;
    for(i=0; i<=31; i++){
        if(i==9)
            printf("Z");
        if(i==18)
            printf("X");
        if(i==27)
            printf("V");

        printf("%c", (i/3)%3+'a');
    }

    return 0;
}
0 Mukul Chauhan · April 28, 2015
Great job.
  • 1

C

107,188 followers
About

One of the most popular languages of all time.

Links
Moderators
Bucky Roberts Administrator