Program to Count Number of Words in a String

Write a program to count number of words in a string without using any function. This type of question generally asked by the interviewer to check the logic of a candidate.

If you are preparing for an interview. Check my previous post on

C Objective questions

Subscribe Our Tutorials

Get Latest Updates on Facebook

Question on Linked List

Program to Count Number of Words in a String

Logic

Run a loop till the end of a string. If a character is not a space, then increment word count by 1. Run a while loop so that it reaches at the end of word (To avoid multiple count of same word) .

WebRewrite

About WebRewrite

I am technology lover who loves to keep updated with latest technology. My interest field is Web Development.
Tagged , , , . Bookmark the permalink.