+ 3
Why compiler show monitered command dumped core?
14 Antworten
+ 3
Jayakrishna
https://code.sololearn.com/c9icw7YY93I5/?ref=app
+ 3
Ipang thanks
+ 2
Jayakrishna Ipang it results garbage value after making changes
+ 2
Jayakrishna thanks
+ 2
Jayakrishna
https://code.sololearn.com/c9icw7YY93I5/?ref=app 🙂
It wasn't possible without your help
+ 1
Focus on <word> counting, garbage and error happens when <word> is 0.
When calculating `avg = letter / word;`
Print value of <letter> and <word> before calculating <avg> to see if it makes a valid/logical calculation.
(Edit)
The test for alphabets at line 12 still need correction, do as follows:
if ((s[i] >= 'a' && s[i] <= 'z') || (s[i] >= 'A' && s[i] <= 'Z'))
0
Share the code, people can't help unless you show that code. Follow this guide on how to share links, in case you didn't know
https://www.sololearn.com/post/74857/?ref=app
0
May be you are accessing a location which is not available, or uninitialized...
0
Roopam Maurya
s[i]!='\0' causing that..
Instead of that use like i<strlen(s).
And use one float or double variable for word or char...
If both are Integer then int/int, you get again Integer value.. So you miss fraction part.
And in loop, s[i] <= 'z' not > greater than..
Same in next comparition...
Check out these...
0
Initialize <word> and <letter> at line 7, these are not automatically initialized to zero.
0
Roopam Maurya
if(S[i] == ' ')
Use single quotes for space comparition..
Edit: sorry, not needed a space to count as char..
I edited code below also.. I hope no further errors...
0
{
if((s[i]>='a'&&s[i]<='z')||(s[i]>='A'&&s[i]<='Z'))
{
letter+=1;
}
if(s[i]==' ')
{
word+=1;
}
}
0
You're welcome Roopam Maurya
0
Roopam Maurya
Wel come..