Warning: mysqli_connect(): (HY000/2002): Connection refused in /home/programc/public_html/wp-content/plugins/wp-pro-quiz/wp-pro-quiz.php on line 38

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /home/programc/public_html/wp-content/plugins/wp-pro-quiz/wp-pro-quiz.php on line 40

Warning: mysqli_num_rows() expects parameter 1 to be mysqli_result, null given in /home/programc/public_html/wp-content/plugins/wp-pro-quiz/wp-pro-quiz.php on line 41

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /home/programc/public_html/wp-content/plugins/wp-pro-quiz/wp-pro-quiz.php on line 45

Warning: mysqli_query() expects parameter 1 to be mysqli, boolean given in /home/programc/public_html/wp-content/plugins/wp-pro-quiz/wp-pro-quiz.php on line 48

Warning: mysqli_fetch_array() expects parameter 1 to be mysqli_result, null given in /home/programc/public_html/wp-content/plugins/wp-pro-quiz/wp-pro-quiz.php on line 49
Program to count the number of alphabets, digits, spaces, special symbols - Get Program Code
Home / Blue J / Program to count the number of alphabets, digits, spaces, special symbols

Program to count the number of alphabets, digits, spaces, special symbols

This is a program to count the total number of letters, digits, blank spaces and special symbols in a given string.

import java.io.*;
class count
{
void main()throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));  
System.out.println("enter the String");
String s=br.readLine();
int i,l,c1=0,c2=0,c3=0,sp=0;
char ch;
l=s.length();
for(i=0;i<l;i++)
{
ch=s.charAt(i);
if(Character.isLetter(ch))
++c1;
else if(Character.isDigit(ch))
++c2;
else if(ch==' ')
++sp;
else
++c3;
}
System.out.println("no of Letter="+c1);
System.out.println("no of Digit="+c2);
System.out.println("no of Spaces="+sp);
System.out.println("no of Symbol="+c3);
}
}

 OUTPUT:

count-the-alphabets-numbers-and-special-symbols

Check Also

Program to check Upper Triangular matrix

What is Upper Triangular Matrix?  An upper triangular matrix is a square matrix in which ...

2 comments

  1. thanxxxxxx you helped a lot in my project!!!!

  2. Can you give code for string manipulation
    Q1- in a sentence of words , the 1 st character and last character of each word must be swapped.
    Eg- input- java is awesome.
    Output – aavj si ewesoma.
    Q2. In a string , calculate the repeated characters and print repeated character in descending order.
    Eg- input- Mississippi.
    Output – s-4
    i-4
    P-2
    M-1.
    Help me out soon guys ..

Leave a Reply

Your email address will not be published. Required fields are marked *

Preventing spam * Time limit is exhausted. Please reload the CAPTCHA.