You are on page 1of 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