this is part of the code:
while((ch=getchar())!='#')
{
if(ch=='.')
{
putchar('!');
count++;
}
if(ch=='!')
{
printf("!!");
count++;
}
else
putchar(ch);
}
I thought the "else" is associated with the second "if", but when it encounters "." it replaces it with "!", and it also prints ".", that means it goes to the last "putchar(ch); ". why is this?
while((ch=getchar())!='#')
{
if(ch=='.')
{
putchar('!');
count++;
}
if(ch=='!')
{
printf("!!");
count++;
}
else
putchar(ch);
}
I thought the "else" is associated with the second "if", but when it encounters "." it replaces it with "!", and it also prints ".", that means it goes to the last "putchar(ch); ". why is this?