+2

Why compiler show monitered command dumped core?

c

1/19/2020 2:31:45 PM

Roopam Maurya

14 Answers

New Answer

+1

Jayakrishna https://code.sololearn.com/c9icw7YY93I5/?ref=app

+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'))

+1

Ipang thanks

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

Jayakrishna Ipang it results garbage value after making changes

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

Jayakrishna thanks

0

Jayakrishna https://code.sololearn.com/c9icw7YY93I5/?ref=app 🙂 It wasn't possible without your help

0

You're welcome Roopam Maurya

0

Roopam Maurya Wel come..