0% found this document useful (0 votes)
37 views

strings: 1.//program To Find Number of Vowels in Given String

The document contains code for two C++ programs. The first program counts the number of vowels in a string input by the user. The second program reverses a string by outputting the characters starting from the last index to the first index.

Uploaded by

Vetty Vignesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

strings: 1.//program To Find Number of Vowels in Given String

The document contains code for two C++ programs. The first program counts the number of vowels in a string input by the user. The second program reverses a string by outputting the characters starting from the last index to the first index.

Uploaded by

Vetty Vignesh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

//Strings

1.//Program to find number of vowels in given string


#include<iostream.h>
#include<conio.h>
#include<stdio.h>
void main()
{
clrscr();
char str[100];
cout<<"Enter string\n";
gets(str);
int nv=0;
for(int i=0;str[i]!='\0';++i)

if(str[i]=='a'||str[i]=='A'||str[i]=='e'||str[i]=='E'||str[i]=='o'||str[i]=='O'||
str[i]=='u'||str[i]=='U'||str[i]=='i'||str[i]=='I')
++nv;
cout<<"No. of vowels "<<nv;
getch();

}
2.//Program to display string from backward
#include<iostream.h>

#include<conio.h>

#include<stdio.h>

void main( )

{

clrscr( );

char str[80];

cout<<"Enter a string:";

gets(str);

for(int l=0; str[l]!='\0';l++); //Loop to find the length of the string

for(int i=l-1;i>=0;i--) //Loop to display the string backwards

cout<<str[i];

getch();

}

You might also like