Sunday, 29 June 2014

C++ program to print upper-case characters in a string using recursion


Here is a C++ program to print upper-case characters in a string using recursion


 SOURCE CODE OUTPUT
#include<iostream>
using namespace std;
void ucas(char *str,int i)
{
    if(str[i]=='\0')
        return ;
    else
        if(str[i]>=65&&str[i]<=90)
             cout<<str[i];
        ucas(str,i+1);
}
int main()
{
    char str[50];
    cout<<"Enter string : ";
    cin.getline(str,50);
    cout<<"Uppercase character of string : ";
    ucas(str,0);
    return 0;
}

Any questions regarding to program please write in comments.

No comments:

Post a Comment