Monday, May 5, 2008

program to count number of characters

Write a program that will count the number of characters in a sentence entered by user.

PROGRAM:

#include <iostream.h>

#include <conio.h>

#include <stdio.h>

#include <string.h>


void main() {

clrscr();

int len;

char ch[200];

cout<<"Program to count number of characters entered by the user: \n";

cout<<"Enter your sentence: \n";

gets(ch);

len=strlen(ch);

cout<<"\ntotal number of characters: "<<len;

getch();

}

No comments: