/******************************************************************************
1. Write a program to give the following output for the given input
*******************************************************************************/
#include<string.h>
int main()
{
char a[100];
scanf("%s",a);
int b=strlen(a);
int i,l,j,f=0;
for(i=1;i<b;i++)
{
if(a[i]>=48 && a[i]<=57)
{
l=a[i]-48;
if(a[i+1]>=48 && a[i+1]<=57)
{
l=(l*10)+(a[i+1]-48);
f=1;
}
for(j=0;j<l;j++)
{
printf("%c",a[i-1]);
}
if(f==1)
i++;
}
}
}
INTERVIEW C QUESTION(ZOHO)
QUESTION:
1. Write a program to give the following output for the given input
Eg 1: Input: a1b10
Output: abbbbbbbbbb
Eg: 2: Input: b3c6d15
Output: bbbccccccddddddddddddddd
The number varies from 1 to 99.
*******************************************************************************/
PROGRAM:
#include <stdio.h>
#include<string.h>
int main()
{
char a[100];
scanf("%s",a);
int b=strlen(a);
int i,l,j,f=0;
for(i=1;i<b;i++)
{
if(a[i]>=48 && a[i]<=57)
{
l=a[i]-48;
if(a[i+1]>=48 && a[i+1]<=57)
{
l=(l*10)+(a[i+1]-48);
f=1;
}
for(j=0;j<l;j++)
{
printf("%c",a[i-1]);
}
if(f==1)
i++;
}
}
}
Comments
Post a Comment