NUMBER OF OCCURRENCES OF A CHARACTER IN A STRING

 ************************************************************************ 

W.A.P TO CHECK THE NUMBER OF OCCURRENCES OF A CHARACTER IN A STRING

************************************************************************  

REGEX MEANS REGULAR EXPRESSION

JAVA Program







   



  
Online compiler

Output:


************************************************************************ 

C Program



Online Compiler 

 

************************************************************************ 

C++ Program

Online Compiler

************************************************************************ 

C# Program


 
 
Output:

************************************************************************ 

PHP Program


Online Compiler

Php is a server side scripting language.

************************************************************************ 

JAVASCRIPT Program

 <script type="text/javascript">

var string = prompt("Enter a string: ");
var letter = prompt("Enter a letter: ");
let strlen = string.length;
alert(strlen);
var counter=0;
for (var i=0; i<strlen; i++ ){
  if(string[i]==letter){
    counter++;
  }
}
console.log(`${string} => ${letter} => ${counter}`);
//case sensitive



</script>

Online Compiler

************************************************************************ 

PYTHON Program

 

Online Compiler: 

************************************************************************  







Comments

Popular posts from this blog

SAME NAME IN CLASS METHOD AND CONSTRUCTOR

PALINDROME NUMBER

FIBONACCI SERIES