#include <stdio.h>
#include <stdlib.h>
void main()
{
char s[40];
int i,j,k=0,c=0;
printf("enter the string: ");
fgets(s,sizeof(s),stdin);
for(i=0;s[i]!='\0';i++)
{
if(s[i]==32)
{
c++;
}
}
if(c%2==0)
{
printf("there is no middle word");
}
else{
j=c/2;
for(i=0;s[i]!='\0';i++)
{
if(s[i]==32)
{
k++;
if(j==k)
{
i++;
while(s[i]!=32)
{
printf("%c",s[i]);
i++;
}
}
}
}
}
}
output shoulbe like this
i love india
where middle word is love
so i have to print middle word
it shows 0 errors but output is wrong