Computer Science, asked by asmataj432, 1 year ago

Write the program in c++ to accept a string and print the total no of vowels in it also print the string in upper and lower case

Answers

Answered by omegads03
22

#include<iostream.h>

#include<string.h>

#include<conio.h>

void main()

{

clrscr();

char line[50];

int i, vowel=0;

cout<<"Enter a string : ";

cin.getline(line, 50);

for(i=0; line[i]!='\0'; i++)

{

 if(line[i]='a' || line[i]='e' || line[i]='i' || line[i]='o' || line[i]='u' || line[i]='A' || line[i]='E' || line[i]='I' || line[i]='O' || line[i]='U')

 {

  vowel = vowel + 1;

 }

}

cout<<"\nThe total number of vowels in the string is : "<<vowel;

for(i=0; i<=strlen(line); i++)

{

 if(line[i]>=97 && line[i]<=122)

 {

  line[i]=line[i]-32;

 }

}

cout<<"\nThe string in Uppercase : "<<line;

for(i=0; i<=strlen(line); i++)

{

 if(line[i]>=65 && line[i]<=90)

 {

  line[i]=line[i]+32;

 }

}

cout<<"\nThe string in Lowercase : "<<line;

getch();

}

Answered by mindfulmaisel
9

"The "program" for the "given problem" will be as follows:

#include<iostream.h>

#include<string.h>

#include<conio.h>

void main()

{

clrscr();

char line[50];

int i, vowel=0;

cout<<"Enter a string : ";

cin.getline(line, 50);

for(i=0; line[i]!='\0'; i++)

{

if(line[i]='a' || line[i]='e' || line[i]='i' || line[i]='o' || line[i]='u' || line[i]='A' || line[i]='E' || line[i]='I' || line[i]='O' || line[i]='U')

 {

vowel = vowel + 1;

}

}

cout<<"\nThe total number of vowels in the string is : "<<vowel;

for(i=0; i<=strlen(line); i++)

{

 if(line[i]>=97 && line[i]<=122)

 {

line[i]=line[i]-32;

}

}

cout<<"\nThe string in Uppercase : "<<line;

for(i=0; i<=strlen(line); i++)

{

 if(line[i]>=65 && line[i]<=90)

 {

line[i]=line[i]+32;

 }

}

cout<<"\nThe string in Lowercase : "<<line;

getch();

}"

Similar questions