Search This Blog

Sunday, July 3, 2011

find out number vowel in a string

find out number vowel in a string

#include<stdio.h>
#include<conio.h>
void main()
{
char a[]="array";
int i,v=0,c=0;
for(i=0;a[i]!=NULL;i++)
{
if(a[i]=='a'||a[i]=='e'||a[i]=='i'||a[i]=='o'||a[i]=='u')
{
v++;
}
else
c++;
}
printf("there are %d vowel and %d consonant",v,c);
getch();
}

Calculate lenth of a String

Calculate lenth of a string without using Library Function

#include<stdio.h>
#include<conio.h>
void main()
{
char a[]="ram";
int i,c=0;
for(i=0;a[i]!=NULL;i++)
{
c++;
}
printf("lenth of the string is %d",c);
getch();
}