Sunday, August 23, 2015

Program To Find Word Length


Q. 95. Write a C++ program to accept a Word and find out length of the Word (the number of characters).



Copy Code:

#include <iostream>
using namespace std;

int main()

{
  int i = 0, len = 0; char ch [50];

  cout << "Enter any Word : ";
  cin >> ch ;

  while (ch [ i ] != '\0' ) 
   {
      len+=1;  i+=1;  
   }
  cout << "Total Number of Characters = " << len;

  return 0;
}


No comments:

Post a Comment