//This program counts the number of words and characters with and without spaces.
//This program contains a new command for the Printf function. More Explanation is given in line 12.
#include <stdio.h>
#include <conio.h>
void main( )
 {
 //*** Variable Declaration ***
 int count=0;
 int word=1;
 char x,y;
 //*** The Main Body ***
 clrscr();
 printf("This program will count the number of characters in a given statement.\nNote that the program will continue until you enter \"0\".\n");
 //The \" command in the previous line, will print the quotation mark on the screen.
 printf("\nenter your statement please:\n");
 while (x!='0')
	{
	scanf("%c",&x);
	count++;
	if (x==' ')
		{
		++word;
		}
	}
 printf("\nThe number of words in your statement is: %d",word);
 printf("\nThe number of characters (with spaces) in your statement is: %d",count);
 printf("\nThe number of characters (without spaces) in your statement is: %d",count-word+1);
 getch();
 /*
 The following lines will check the value of x after the end of the program.
 This test shows the function of scanf, while we enter a string instead of a single character.
 By entering a string, all the characters will be scanned and saved in the defined variable respectively (x in this program).
 But each time, the scanned character will be replaced by the next character of the string.
 */
 printf("\n\nChecking the value of variable x:\n");
 printf("%c",x);
 getch();
 }