Well, there are a few problems, iāll just list them quickly
Firstly you didnāt take care of input at start,number of test cases
, you need to take a input (say T) and run the code inside a loop iterating T times
Secondly in the for loop, you need to check from i=0 to i=strlen(word)-1 and not ā40ā
You dont need this if condition
if(word[i]>=0 && word[i]<=9)
{
break;
}
Take out the getchar() at the end
Then it will be fine i hope, try the correction yourself and see if you get it right
edit : add a new line after printing āholesā
Cheers
P.S - you can check my last submission of this problem, i did the mentioned changes and submitted it
I did not understand by what means you gave the loop till i<=40.
Shouldnāt it be i<strlen(word)?
Then in the question it is clearly given that the characters in the text will be from āAā-āZā
You need not check that caseā¦Even if you check it it will not cause any wrong answer.But if we are sure that such a thing does not exist then why do we need to waste the time for checking that?
Moreover we need not pause the output instead using getchar().
Hope you got what i meantā¦
Happy codingā¦
you Should make a loop like āfor(j=0;j< i;j++)ā where āi = strlen(word)ā instead of āfor(i=0;i<=40;i++)ā
you donāt need to check the given inputā¦ in the text file only capital letters are allowed(A-Z) so you donāt need to add extra if conditionā¦ āif(word[i]>=0 && word[i]<=9)ā.
and you donāt need to add getchar() at the endā¦
i just input the answer like this. but keep wrong answer. i donāt know why. if i input 2 the output is 0. if i input other words it can compiled succesfully.
You still did not take the number of test cases, you need to take an int input first (say T) and then input word T time,
You donāt need to put the getchar() at the end.
Lastly while inputing the string in word[100], the scanf statement you used is wrong, ā&wordā is not correct, it should be either only āwordā or ā&word[0]ā