Wednesday, March 20, 2013

C Language Example # 40 Counter Space and Constant from Character Array

C Language Example # 40 Counter Space and Constant from Character Array..

* Program will count number of spaces and constant characters
.

//Written by : Latest Technology Guide
//Title : C Language Example # 40 Counter Space and Constant from Character Array..


#include <stdio.h>
#include <conio.h>
void main()
{
    clrscr();
    int  i,sp=0,co=0;
    char ch[30]={0};

    printf("\n Now Enter Text : ");
    gets(ch);

    i=0;

    do
    {
        if(ch[i]==32)
            sp=sp+1;
        else
            co=co+1;
        i++;
    }while(ch[i]!=NULL);

    printf("\n\t\t *****: Detail Description :***** ");

    printf("\n Constant = %3d",co);
    printf("\n Spaces   = %3d",sp);

    getch();
}

Output:
* We think there is no need of output. Output is very simple !

--------------------------------------------------------------------------------
Explanation of C Programming Language Example # 40 Counter Space and Constant from Character Array.

* You need to enter character array.
* This program will count number of space and constant.


Note: All programs are developed and tested using Turbo C++ 3.0 under Windows XP. We just want to provide guidelines to the users. If you are using any other Compiler or other operating system they you need to modify this program as per your requirements.

No comments:

Post a Comment

Post a Comment