Pages

Write a Programe to count blank spaces, tabs and new lines.

Friday 19 April 2013


#include <stdio.h>
#include <conio.h>
main()
{
      int tab=0, new_line=0, blank=0, i;
      char string[100];
      char ch;
      printf("Enter data. Press \'.\' when complete.\n");
      ch=getche();
      i=0;
      while(ch!='.')
      {
                    ch=getche();
                    string[i]=ch;
                    if(ch==13)
                    {
                                printf("\n");
                                new_line++;        
                    }
                    if(ch==32)
                    {
                              blank++;      
                    }
                    if(ch==9)
                    {
                             tab++;      
                    }
                    i++;        
      }
      printf("\nYou have enter %d Enter(new lines).\nYou have enter %d blank spaces. \nYou have enter %d tabs.", new_line, blank, tab);
      getch();  
}

 

Search Box

Most Reading

Contact Form

Name

Email *

Message *