This code is for finding nearest Vowel whatever Character you enter by your keyboard.
#include <stdio.h>
int main()
{
int a[10]={65,69,73,79,85,97,101,105,111,117}; //Array of Vowel (a,e,i,o,u,A,E,I,O,U)
char ch;
int temp,temp1,i;
printf ("enter character\n");
scanf ("%c",&ch);
temp=ch-a[0];
for (i=0;i<10&&((ch-a[i])>=0);i++)
{
if( ch==a[i] )
{
printf ("nearest vowel is: %c\n",a[i]);
return 0;
}
if( temp>(ch-a[i]) )
{
temp1=a[i];
}
}
printf ("nearest vowel is %c\n",temp1);
return 0;
}
No comments:
Post a Comment