mirror of
https://codeberg.org/DansLeRuSH/c-plus-plus-exercises.git
synced 2024-11-21 11:18:07 +00:00
Count the number of 'a' in a string
This commit is contained in:
parent
899f80447e
commit
9ce46aec8f
1 changed files with 20 additions and 0 deletions
20
EX06_compter_les_a.cpp
Normal file
20
EX06_compter_les_a.cpp
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
//Auteur : Franck ALBARET
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <conio.h>
|
||||||
|
|
||||||
|
int main (void)
|
||||||
|
{
|
||||||
|
int i=0;
|
||||||
|
int cpt=0;
|
||||||
|
char Texte [60];
|
||||||
|
puts ("Veuillez taper votre texte :\n");
|
||||||
|
gets(Texte);
|
||||||
|
while(Texte[i]!='\0')
|
||||||
|
{
|
||||||
|
if (Texte[i]=='a')
|
||||||
|
cpt=cpt+1;
|
||||||
|
i=i+1;
|
||||||
|
}
|
||||||
|
printf ("\n\n Le nombre de A est %i\n",cpt);
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in a new issue