/*................................................................................................................................................
File Name: rec30.c
Program : Write a program to display only the names which has vowels; accept the names through command line
Author : sujithbaby440@gmail.com
Date : 26-11-2014
...................................................................................................................................................*/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int vowel(char str[10]);
main(int argc,char *argv[])
{
int i,n,j,res,a;
char str[10],arg[10];
for(i=1;i<argc;i++){
a=vowel(argv[i]);
if(a)
printf("%s\n",argv[i]);
}
}
int vowel(char str[10])
{
int i=0,flag=0;
while(str[i]!='\0'){
if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u'){
flag=1;
break;
}
else if(str[i]=='A'||str[i]=='E'||str[i]=='I'||str[i]=='O'||str[i]=='U'){
flag=1;
break;
}
i++;
}
return flag;
}
OUTPUT:-
1) /a.out hai friends how are you?
hai
friends
how
are
you?
2) ./a.out What is your age? Is it 23
What
is
your
age?
Is
It
File Name: rec30.c
Program : Write a program to display only the names which has vowels; accept the names through command line
Author : sujithbaby440@gmail.com
Date : 26-11-2014
...................................................................................................................................................*/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int vowel(char str[10]);
main(int argc,char *argv[])
{
int i,n,j,res,a;
char str[10],arg[10];
for(i=1;i<argc;i++){
a=vowel(argv[i]);
if(a)
printf("%s\n",argv[i]);
}
}
int vowel(char str[10])
{
int i=0,flag=0;
while(str[i]!='\0'){
if(str[i]=='a'||str[i]=='e'||str[i]=='i'||str[i]=='o'||str[i]=='u'){
flag=1;
break;
}
else if(str[i]=='A'||str[i]=='E'||str[i]=='I'||str[i]=='O'||str[i]=='U'){
flag=1;
break;
}
i++;
}
return flag;
}
OUTPUT:-
1) /a.out hai friends how are you?
hai
friends
how
are
you?
2) ./a.out What is your age? Is it 23
What
is
your
age?
Is
It
No comments:
Post a Comment