Click here to Skip to main content
14,325,064 members

C program to print number of characters as per the count

Nuruddin Warsi asked:

Open original thread
You are the encoded form of a data string as follows: consecutive
occurrences of a letter (up to 9) are represented by the letter
followed by the number of occurrences.

For example, the string


stands for the string


- that is, 12 consecutive occurrences of a, followed by 2 bs, and then
4 cs, followed by a d and finally c

Given an encoded form, you have to output the data string.

Its not entering the two if conditions

[edit]Tidy up, code block added, indentation sorted, spurious blank lines removed - OriginalGriff[/edit]

What I have tried:

int main()
    int i,n,s;
    char a[100];
        if((a[i]>='a' && a[i]<='z')&&(a[i+1]>='a'&& a[i+1]<='z'))
        else if((a[i]>='a' && a[i]<='z') &&(a[i+1]>='2' && a[i+1]<='9'))
    if(a[s-1]>='a'&& a[s-1]<='z')
    return 0;
Tags: C


When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100