First uppercase letter in a string ( Iterative and Recursive ) | C ++ program to find the first uppercase letter using linear search ; Function to find string which has first character of each word . ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; char first ( string str ) { for ( int i = 0 ; i < str . length ( ) ; i ++ ) if ( isupper ( str [ i ] ) ) return str [ i ] ; return 0 ; } int main ( ) { string str = " geeksforGeeKS " ; char res = first ( str ) ; if ( res == 0 ) cout << " No ▁ uppercase ▁ letter " ; else cout << res << " STRNEWLINE " ; return 0 ; }