New Member FAQ | Forums | Earn Revenue


Resources Entrance Ask Experts Exam Papers Jobs English Projects Universities Colleges Courses Schools Training My India



My Profile
Active Members
TodayLast 7 Days more...



Awards & Gifts
Online Exams

Fresher Jobs


Our fresher job section is exclusively for fresh graduates! Find jobs for freshers in major Indian cities including Bangalore, Chennai, Hyderabad, Pune or Kochi

Resources


Find educational articles, blogs, discussion threads and other resources.

Colleges


Find details about any college in India or search for courses.

website counter



C program to count the number of words, lines and characters in a text


Posted Date:     Total Responses: 0    Posted By: Sunil Reddy   Member Level: Platinum   Points/Cash: 2   


#include
main()
{
char line[81], ctr;
int i,c,end = 0, characters = 0, words = 0, lines = 0;
printf(“\nKEY IN THE TEXT “);
printf(“GIVE ONE SPACE AFTER EACH WORD.\n”);
printf(“WHEN COMPLETED, PRESS ‘ENTER’\n\n”);
while (end == 0)
{
c = 0;
while ((ctr = getchar()) != ‘\n’)
line[c++] = ctr;
line[c] = ‘\0’;
if (line[0] == ‘\0’)
break;
else
{
words++;
for (i = 0; line[i] != ‘\0’; i++)
if (line[i] == ‘ ‘ || line[i] == ‘\t’)
words++;
}
lines = lines + 1;
characters = characters + strlen(line);
}
printf(“\n”);
printf(“\nNumber of lines = %d”, lines);
printf(“\nNumber of words = %d”, words);
printf(“\nNumber of characters = %d”, characters);
}


Project Feedbacks


No feedbacks found. Be the first to respond and make money from revenue sharing program.

Post Feedback
You must Sign In to post a feedback.
Next Project: C program for selection sort
Previous Project: C program to calculate student-wise total for three students using an array

Return to Project Index

Post New Project


Related Projects



Advertise Here





Contact Us   Advertise   Editors    Privacy Policy    Terms Of Use   

ISC Technologies.
2006 - 2009 All Rights Reserved.