character Occurance and vowel find

#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <ctype.h>
#include <process.h>

char STR [50],str [1];
int x,i=0,num=0,PCO,NOC;
void choices ()
{
printf ("[1] Input a String\n");
printf ("[2] Count the Vowel of a String\n");
printf ("[3] Locate the Position of Character Occurance\n");
printf ("[4] The Number of Occurance by Character\n");
printf ("[5] EXIT\n\n");
}
void case1 ()
{
clrscr ();
printf ("Input a String\n\n");
printf ("Please enter a String:");
scanf ("%s",&STR);
printf ("\n\nyou have entered a string:%s",STR);
getch ();
}
void case2 ()
{ clrscr ();
printf ("Count The Vowels of a String\n\n");
printf ("\n\nyour string:%s",STR);
for (i=0; STR[i] != '\0'; i++)
{
STR [i]= tolower (STR[i]);
if (STR[i]=='a') num = num + 1;
else if (STR[i]=='e') num = num + 1;
else if (STR[i]=='i') num = num + 1;
else if (STR[i]=='o') num = num + 1;
else if (STR[i]=='u') num = num + 1;
}
printf ("\n\n%i",num);
getch ();
}
void case3 ()
{
clrscr ();
printf ("Locate The Position of Character per Occurance\n\n");
printf ("\n\nyour string:%s",STR);
printf ("\n\nEnter a Character:");
scanf ("%s",str);
for (i=0; STR[i] != '\0'; i++)
{
if (STR[i]==str[0]) {printf ("\n%i\n",i+1);}
}
getch ();
}
void case4 ()
{
clrscr ();
printf ("The Number of Occurance by Character\n\n");
printf ("\n\nyour string:%s",STR);
printf ("\n\nEnter a Character:");
scanf ("%s",str);
for (i=0; STR[i] != '\0'; i++)
{
if (STR[i]==str[0]) {NOC++;}
}
printf ("\n\n The Number of Occurance: %i",NOC);
getch ();
}
main (void)
{ clrscr ();
do {clrscr ();
choices ();
printf ("Please Enter Your Choice:");
scanf ("%i",&x);
switch (x)
{case 1: case1 ();break;
case 2:{
if (STR[0]=='\0') {printf ("Please Enter String"),getch (); break;}
case2 ();break;
}
case 3:{
if (STR[0]=='\0') {printf ("Please Enter String"),getch (); break;}
case3 ();break;
}
case 4:{
if (STR[0]=='\0') {printf ("Please Enter String"),getch (); break;}
case4 ();break;
}
case 5: exit;
}
}while (x!=5);
getch ();
return 0;
}
Topic archived. No new replies allowed.