Here is a C++ program to print lower-case characters in a string using recursion
SOURCE CODE OUTPUT
#include<iostream>
using namespace std;
void lcas(char *str,int i)
{
if(str[i]=='\0')
return ;
else
if(str[i]>=97&&str[i]<=122)
cout<<str[i];
lcas(str,i+1);
}
int main()
{
char str[50];
cout<<"Enter string : ";
cin.getline(str,50);
cout<<"Lowercase character of string : ";
lcas(str,0);
return 0;
}
using namespace std;
void lcas(char *str,int i)
{
if(str[i]=='\0')
return ;
else
if(str[i]>=97&&str[i]<=122)
cout<<str[i];
lcas(str,i+1);
}
int main()
{
char str[50];
cout<<"Enter string : ";
cin.getline(str,50);
cout<<"Lowercase character of string : ";
lcas(str,0);
return 0;
}
Any questions regarding to program please write in comments.
No comments:
Post a Comment