frequency

169

#take user input
String = input('Enter the string :')
#take character input
Character = input('Enter character :')
#initiaalize int variable to store frequency
frequency = 0
#use count function to count frequency of character
frequency = String.count(Character)
#count function is case sencetive 
#so it print frequency of Character according to given Character
print(str(frequency) + ' is the frequency of given character')
printf("Enter n: ");
  scanf("%d", &n);
  
  int elem[n];
  
  printf("Enter elements: \n");
  
  for(x=0; x<n; x++){
  
  scanf("%d", &elem[x]);
  }
  
  int y;
  
  printf("Enter y: ");
  scanf("%d",&y);
  
  for(z=0; z<n; z++){
  
  		if(elem[z]==y){
  			count++;
		  }
  
  }
      printf("FREQUENCY: %d",count);

Comments

Submit
0 Comments