wrong answer for Transform the Expression

i have written c program for Transform the Expression. checked it for many test cases. it worked fine. when i submit i showed wrong answer. i have cross checked the same testcases with other accepted submission. the output of my code and the accepted one was same. my c code is

#include<stdio.h>
#include<string.h>
char stk[1000];
int j;
int main()
{
	int num,i,len,k;
	char ch[1000];
	scanf("%d",&num);
	while(num)
	{
		printf("enter the elements\n");
		scanf("%s",ch);
		num--;
		//printf("%s\n",ch);
		len=strlen(ch);
		//printf("%d",len);
		j=0;
		k=0;
		while(k<=len)
		{
			if((ch[k]>='a' && ch[k]<='z'))
			{
				printf("%c",ch[k]);
				k++;
			}
			else if(ch[k]==')')
			{
				k++;
				j--;
				while(stk[j]!='(')
				{
					printf("%c",stk[j]);
					j--;
				}
			}
			else
			{
				//printf("hellloooo\n");
				stk[j]=ch[k];
				j++;
				k++;
			}
		}
	}
	return 0;
}

please help in moving forward. waiting for reply

You have to read FAQ, it states:

If your program starts by printing ‘Enter the number’ and the problem does not tell you to do so, then since this is not part of the correct output, you will be never be judged correct regardless of what the rest of your program does.

and that’s the problem in your solution.

3 Likes

Why is that question marked as community wiki ?