Program to uncompress a string ie a2b3c4 to aabbbcccc

Below is the program to uncompress a string

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
int main()
{
char str[100]="a2b3c4d8u7";
for(int i=0;str[i]!='\0';i++)
{
if(i%2!=0)
{
for(int j=0;j<atoi(&str[i]);j++)
{
printf("%c",str[i-1]);
}
}
}
getch();
}

Want to become a Data Engineer? Check out below blog posts 

Comments

  1. what is the code for aaaafff to a4f3?

    ReplyDelete
  2. instead of checking if its an odd position... start running j loop from i+1.

    ReplyDelete

Post a Comment

Popular posts from this blog

Tricky Questions or Puzzles in C

Number series arrangement puzzles