Page 1 of 1

Why RE

Posted: Wed Jul 11, 2007 4:17 am
by ranacse05
Here is my code plz tell me where is the bug

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



int main()
{
int i,x,y,k;
char a[100];

while(gets(a))
{
char b[4]={0};
int ln=strlen(a);

for(k=0;k<ln;)
{
if(isdigit(a[k]))
{
{

if((a[k]-'0')<3)
{
b[1]=a[k];
b[0]=a[k+1];
b[2]=a[k-1];
}
else
{
b[1]=a[k];
b[0]=a[k+1];
}
k=k+2;
}
x=atoi(b);
printf("%c",x);

}

else
{
x=a[k];
for(i=0;;i++)
{
y=x%10;
printf("%d",y);
x=x/10;
if(x==0)
break;
}
k++;
}

}
printf("\n");
}
return 0;
}

Posted: Wed Jul 11, 2007 5:14 am
by mmonish
U have to mention the prob number. Before creating a new thread search the board first.