C and C++ and Java Programs
Total Pageviews
Thursday, 7 July 2016
Wednesday, 6 July 2016
Sunday, 3 July 2016
Delete a vowel from a String- C Program
Input- Absolutely
Output- bsltly
PROGRAM
//Delete vowels from a String
#include<stdio.h>
#include<string.h>
int main()
{
char s[20];
int i=0,j=0;
scanf("%s",&s);
for(i=0;i<=strlen(s);i++)
{
if((s[i]=='a')||(s[i]=='e')||(s[i]=='i')||(s[i]=='o')||(s[i]=='u'))
s[i]=' ';
else
s[j++]=s[i];
}
printf("%s",s);
return 0;
}
OUTPUT
"strcmp" C- Example
Input- red
Output-Its a Dusk
Input-green
Output-Its a Dawn
Input- #Any other Color
Output-Invalid Input
--Program--
#include<stdio.h>
int main()
{
char s[20];
scanf("%s",&s);
if(strcmp(s,"blue")==0)
printf("Its a Dawn");
else if(strcmp(s,"red")==0)
printf("Its a dusk");
else printf("Invalid Input");
return 0;
}
OUTPUT
Output-Its a Dusk
Input-green
Output-Its a Dawn
Input- #Any other Color
Output-Invalid Input
--Program--
#include<stdio.h>
int main()
{
char s[20];
scanf("%s",&s);
if(strcmp(s,"blue")==0)
printf("Its a Dawn");
else if(strcmp(s,"red")==0)
printf("Its a dusk");
else printf("Invalid Input");
return 0;
}
OUTPUT
Subscribe to:
Posts (Atom)