YAMILDIAZ

ejemplo 9

Jun 14th, 2023
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | Source Code | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4.  
  5.  
  6.  
  7. int main(){
  8. const int tam=50;
  9. char frase[tam];
  10. char caracter;
  11. int iguales=0;
  12.  
  13. cout<<"caracter: ";
  14. cin>>caracter;
  15. cin.ignore();
  16. cout<<"ingrese un frase: ";
  17. cin.getline(frase, tam);
  18.  
  19.  
  20.  
  21. for (int i = 0; i < tam; i++){
  22.       if (frase[i]==caracter){
  23.             iguales++;
  24.       }
  25. }
  26. cout<<iguales;
  27.  
  28. cout<<endl;
  29. system("pause");
  30. return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment