dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX_CHARS = 26 ; void longestSubseqWithK ( string str , int k ) { int n = str . size ( ) ; int freq [ MAX_CHARS ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) freq [ str [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < n ; i ++ ) if ( freq [ str [ i ] - ' a ' ] >= k ) cout << str [ i ] ; } int main ( ) { string str = " geeksforgeeks " ; int k = 2 ; longestSubseqWithK ( str , k ) ; return 0 ; }

Index/key variables: MAX_CHARS, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void generate ( set < string > & st , string s ) { if ( s . size ( ) == 0 ) return ; if ( st . find ( s ) == st . end ( ) ) { st . insert ( s ) ; for ( int i = 0 ; i < s . size ( ) ; i ++ ) { string t = s ; t . erase ( i , 1 ) ; generate ( st , t ) ; } } return ; } int main ( ) { string s = " xyz " ; set < string > st ; set < string > :: iterator it ; generate ( st , s ) ; for ( auto it = st . begin ( ) ; it != st . end ( ) ; it ++ ) cout << * it << endl ; return 0 ; }

Accumulator variables: i, it, stdc
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; unordered_set < string > st ; void subsequence ( string str ) { for ( int i = 0 ; i < str . length ( ) ; i ++ ) { for ( int j = str . length ( ) ; j > i ; j -- ) { string sub_str = str . substr ( i , j ) ; st . insert ( sub_str ) ; for ( int k = 1 ; k < sub_str . length ( ) ; k ++ ) { string sb = sub_str ; sb . erase ( sb . begin ( ) + k ) ; subsequence ( sb ) ; } } } } int main ( ) { string s = " aabc " ; subsequence ( s ) ; for ( auto i : st ) cout << i << " ▁ " ; cout << endl ; return 0 ; }

Accumulator variables: i, j, k, stdc
Iterator variables: i, j, k
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printSubSeqRec ( string str , int n , int index = -1 , string curr = " " ) { if ( index == n ) return ; if ( ! curr . empty ( ) ) { cout << curr << " STRNEWLINE " ; } for ( int i = index + 1 ; i < n ; i ++ ) { curr += str [ i ] ; printSubSeqRec ( str , n , i , curr ) ; curr = curr . erase ( curr . size ( ) - 1 ) ; } return ; } void printSubSeq ( string str ) { printSubSeqRec ( str , str . size ( ) ) ; } int main ( ) { string str = " cab " ; printSubSeq ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: curr, i, stdc
Iterator variables: i
C++ program:
#include <iostream>
#include <string>
using namespace std ; int countSubstrs ( string str , int i , int j , int n ) { if ( n == 1 ) return 1 ; if ( n <= 0 ) return 0 ; int res = countSubstrs ( str , i + 1 , j , n - 1 ) + countSubstrs ( str , i , j - 1 , n - 1 ) - countSubstrs ( str , i + 1 , j - 1 , n - 2 ) ; if ( str [ i ] == str [ j ] ) res ++ ; return res ; } int main ( ) { string str = " abcab " ; int n = str . length ( ) ; cout << countSubstrs ( str , 0 , n - 1 , n ) ; }

Index/key variables: i, j
Accumulator variables: res
C++ program:
#include <bits/stdc++.h>
using namespace std ; int countManipulations ( string s1 , string s2 ) { int count = 0 ; int char_count [ 26 ] ; for ( int i = 0 ; i < 26 ; i ++ ) { char_count [ i ] = 0 ; } for ( int i = 0 ; i < s1 . length ( ) ; i ++ ) char_count [ s1 [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < s2 . length ( ) ; i ++ ) { char_count [ s2 [ i ] - ' a ' ] -- ; } for ( int i = 0 ; i < 26 ; ++ i ) { if ( char_count [ i ] != 0 ) { count += abs ( char_count [ i ] ) ; } } return count / 2 ; } int main ( ) { string s1 = " ddcf " ; string s2 = " cedk " ; cout << countManipulations ( s1 , s2 ) ; }

Index/key variables: i
Accumulator variables: count, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX_CHAR = 26 ; int leastCount ( string s1 , string s2 , int n ) { int count1 [ MAX_CHAR ] = { 0 } ; int count2 [ MAX_CHAR ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) { count1 [ s1 [ i ] - ' a ' ] += 1 ; count2 [ s2 [ i ] - ' a ' ] += 1 ; } int res = 0 ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { if ( count1 [ i ] != 0 ) { res += abs ( count1 [ i ] - count2 [ i ] ) ; } } return res ; } int main ( ) { string s1 = " abc " ; string s2 = " cdd " ; int len = s1 . length ( ) ; int res = leastCount ( s1 , s2 , len ) ; cout << res << endl ; return 0 ; }

Index/key variables: MAX_CHAR, i
Accumulator variables: i, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX_CHAR = 26 ; char stringPalindrome ( string A , string B ) { int countA [ MAX_CHAR ] = { 0 } ; int countB [ MAX_CHAR ] = { 0 } ; int l1 = A . length ( ) , l2 = B . length ( ) ; for ( int i = 0 ; i < l1 ; i ++ ) countA [ A [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < l2 ; i ++ ) countB [ B [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < 26 ; i ++ ) if ( ( countA [ i ] > 1 && countB [ i ] == 0 ) ) return ' A ' ; return ' B ' ; } int main ( ) { string a = " abcdea " ; string b = " bcdesg " ; cout << stringPalindrome ( a , b ) ; return 0 ; }

Index/key variables: MAX_CHAR, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
#include <stdlib.h>
#include <string.h>
using namespace std ; void printLCSubStr ( char * X , char * Y , int m , int n ) { int LCSuff [ m + 1 ] [ n + 1 ] ; int len = 0 ; int row , col ; for ( int i = 0 ; i <= m ; i ++ ) { for ( int j = 0 ; j <= n ; j ++ ) { if ( i == 0 j == 0 ) LCSuff [ i ] [ j ] = 0 ; else if ( X [ i - 1 ] == Y [ j - 1 ] ) { LCSuff [ i ] [ j ] = LCSuff [ i - 1 ] [ j - 1 ] + 1 ; if ( len < LCSuff [ i ] [ j ] ) { len = LCSuff [ i ] [ j ] ; row = i ; col = j ; } } else LCSuff [ i ] [ j ] = 0 ; } } if ( len == 0 ) { cout << " No ▁ Common ▁ Substring " ; return ; } char * resultStr = ( char * ) malloc ( ( len + 1 ) * sizeof ( char ) ) ; while ( LCSuff [ row ] [ col ] != 0 ) { row -- ; col -- ; } cout << resultStr ; } int main ( ) { char X [ ] = " OldSite : GeeksforGeeks . org " ; char Y [ ] = " NewSite : GeeksQuiz . com " ; int m = strlen ( X ) ; int n = strlen ( Y ) ; printLCSubStr ( X , Y , m , n ) ; return 0 ; }

Index/key variables: col, i, j, row
Accumulator variables: col, i, j, row
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; string findFirstRepeated ( string s ) { istringstream iss ( s ) ; string token ; unordered_map < string , int > setOfWords ; while ( getline ( iss , token , ' ▁ ' ) ) { if ( setOfWords . find ( token ) != setOfWords . end ( ) ) else setOfWords . insert ( make_pair ( token , 1 ) ) ; } istringstream iss2 ( s ) ; while ( getline ( iss2 , token , ' ▁ ' ) ) { int count = setOfWords [ token ] ; if ( count > 1 ) { return token ; } } return " NoRepetition " ; } int main ( ) { string s ( " Ravi ▁ had ▁ been ▁ saying ▁ that ▁ he ▁ had ▁ been ▁ there " ) ; string firstWord = findFirstRepeated ( s ) ; if ( firstWord != " NoRepetition " ) cout << " First ▁ repeated ▁ word ▁ : : ▁ " << firstWord << endl ; else cout << " No ▁ Repetitionn " ; return 0 ; }

Index/key variables: token
Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string findFirstRepeated ( string s ) { istringstream iss ( s ) ; string token ; set < string > setOfWords ; while ( getline ( iss , token , ' ▁ ' ) ) { if ( setOfWords . find ( token ) != setOfWords . end ( ) ) { return token ; } setOfWords . insert ( token ) ; } return " NoRepetition " ; } int main ( ) { string s ( " Ravi ▁ had ▁ been ▁ saying ▁ that ▁ he ▁ had ▁ been ▁ there " ) ; string firstWord = findFirstRepeated ( s ) ; if ( firstWord != " NoRepetition " ) cout << " First ▁ repeated ▁ word ▁ : : ▁ " << firstWord << endl ; else cout << " No ▁ Repetitionn " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int substringConversions ( string str , int k , int b ) { for ( int i = 0 ; i + k <= str . size ( ) ; i ++ ) { string sub = str . substr ( i , k ) ; int sum = 0 , counter = 0 ; for ( int i = sub . size ( ) - 1 ; i >= 0 ; i -- ) { sum = sum + ( ( sub . at ( i ) - '0' ) * pow ( b , counter ) ) ; counter ++ ; } cout << sum << " ▁ " ; } } int main ( ) { string str = "12212" ; int b = 3 , k = 3 ; substringConversions ( str , b , k ) ; return 0 ; }

Accumulator variables: counter, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX_CHAR = 256 ; int countBalance ( char * str ) { int leftVisited [ MAX_CHAR ] = { 0 } ; int rightVisited [ MAX_CHAR ] = { 0 } ; for ( int i = 0 ; i < n ; i ++ ) rightVisited [ str [ i ] ] ++ ; int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { leftVisited [ str [ i ] ] ++ ; rightVisited [ str [ i ] ] -- ; int j ; for ( j = 0 ; j < MAX_CHAR ; j ++ ) { if ( ( leftVisited [ j ] == 0 && rightVisited [ j ] != 0 ) || ( leftVisited [ j ] != 0 && rightVisited [ j ] == 0 ) ) break ; } if ( j == MAX_CHAR ) res ++ ; } return res ; } int main ( ) { char str [ ] = " abaababa " ; cout << countBalance ( str ) ; return 0 ; }

Index/key variables: MAX_CHAR, i, j
Accumulator variables: i, j, res, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int findFlips ( char str [ ] , int n ) { char last = ' ▁ ' ; int res = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( last != str [ i ] ) res ++ ; last = str [ i ] ; } return res / 2 ; } int main ( ) { char str [ ] = "00011110001110" ; int n = strlen ( str ) ; cout << findFlips ( str , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, res, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int findLen ( string & A , int n , int k , char ch ) { int maxlen = 1 ; int cnt = 0 ; int l = 0 , r = 0 ; while ( r < n ) { if ( A [ r ] != ch ) ++ cnt ; while ( cnt > k ) { if ( A [ l ] != ch ) -- cnt ; ++ l ; } maxlen = max ( maxlen , r - l + 1 ) ; ++ r ; } return maxlen ; } int answer ( string & A , int n , int k ) { int maxlen = 1 ; for ( int i = 0 ; i < 26 ; ++ i ) { maxlen = max ( maxlen , findLen ( A , n , k , i + ' A ' ) ) ; maxlen = max ( maxlen , findLen ( A , n , k , i + ' a ' ) ) ; } return maxlen ; } int main ( ) { int n = 5 , k = 2 ; string A = " ABABA " ; cout << " Maximum ▁ length ▁ = ▁ " << answer ( A , n , k ) << endl ; n = 6 , k = 4 ; string B = " HHHHHH " ; cout << " Maximum ▁ length ▁ = ▁ " << answer ( B , n , k ) << endl ; return 0 ; }

Index/key variables: l, r
Iterator variables: i
C++ program:
#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std ; void printAnagram ( unordered_map < string , vector < string > > & store ) { for ( auto it : store ) { vector < string > temp_vec ( it . second ) ; int size = temp_vec . size ( ) ; for ( int i = 0 ; i < size ; i ++ ) cout << temp_vec [ i ] << " ▁ " ; cout << " STRNEWLINE " ; } } void storeInMap ( vector < string > & vec ) { unordered_map < string , vector < string > > store ; for ( int i = 0 ; i < vec . size ( ) ; i ++ ) { string tempString ( vec [ i ] ) ; sort ( tempString . begin ( ) , tempString . end ( ) ) ; store [ tempString ] . push_back ( vec [ i ] ) ; } printAnagram ( store ) ; } int main ( ) { vector < string > arr ; arr . push_back ( " geeksquiz " ) ; arr . push_back ( " geeksforgeeks " ) ; arr . push_back ( " abcd " ) ; arr . push_back ( " forgeeksgeeks " ) ; arr . push_back ( " zuiqkeegs " ) ; arr . push_back ( " cat " ) ; arr . push_back ( " act " ) ; arr . push_back ( " tca " ) ; storeInMap ( arr ) ; return 0 ; }

Index/key variables: i, tempString
Accumulator variables: i
Iterator variables: i, it
C++ program:
#include <bits/stdc++.h>
using namespace std ; void allCharactersSame ( string s ) { set < char > s1 ; for ( int i = 0 ; i < s . length ( ) ; i ++ ) s1 . insert ( s [ i ] ) ; if ( s1 . size ( ) == 1 ) cout << " YES " ; else cout << " NO " ; } int main ( ) { string str = " nnnn " ; allCharactersSame ( str ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printMinIndexChar ( string str , string patt ) { int minIndex = INT_MAX ; int m = str . size ( ) ; int n = patt . size ( ) ; for ( int i = 0 ; i < n ; i ++ ) { for ( int j = 0 ; j < m ; j ++ ) { if ( patt [ i ] == str [ j ] && j < minIndex ) { minIndex = j ; break ; } } } if ( minIndex != INT_MAX ) cout << " Minimum ▁ Index ▁ Character ▁ = ▁ " << str [ minIndex ] ; else cout << " No ▁ character ▁ present " ; } int main ( ) { string str = " geeksforgeeks " ; string patt = " set " ; printMinIndexChar ( str , patt ) ; return 0 ; }

Index/key variables: i, j, minIndex
Accumulator variables: i, j, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printMinIndexChar ( string str , string patt ) { unordered_map < char , int > um ; int minIndex = INT_MAX ; int m = str . size ( ) ; int n = patt . size ( ) ; - for ( int i = 0 ; i < m ; i ++ ) if ( um . find ( str [ i ] ) == um . end ( ) ) um [ str [ i ] ] = i ; for ( int i = 0 ; i < n ; i ++ ) if ( um . find ( patt [ i ] ) != um . end ( ) && um [ patt [ i ] ] < minIndex ) minIndex = um [ patt [ i ] ] ; if ( minIndex != INT_MAX ) cout << " Minimum ▁ Index ▁ Character ▁ = ▁ " << str [ minIndex ] ; else cout << " No ▁ character ▁ present " ; } int main ( ) { string str = " geeksforgeeks " ; string patt = " set " ; printMinIndexChar ( str , patt ) ; return 0 ; }

Index/key variables: i, minIndex
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX_CHAR = 26 ; bool checkCorrectOrNot ( string s ) { int count1 [ MAX_CHAR ] = { 0 } ; int count2 [ MAX_CHAR ] = { 0 } ; int n = s . length ( ) ; if ( n == 1 ) return true ; for ( int i = 0 , j = n - 1 ; i < j ; i ++ , j -- ) { count1 [ s [ i ] - ' a ' ] ++ ; count2 [ s [ j ] - ' a ' ] ++ ; } for ( int i = 0 ; i < MAX_CHAR ; i ++ ) if ( count1 [ i ] != count2 [ i ] ) return false ; return true ; } int main ( ) { string s = " abab " ; if ( checkCorrectOrNot ( s ) ) cout << " Yes STRNEWLINE " ; else cout << " No STRNEWLINE " ; return 0 ; }

Index/key variables: MAX_CHAR, i, j
Accumulator variables: i, j, stdc
Iterator variables: i
C++ program:
#include <iostream>
#include <cstring>
using namespace std ; int count9s ( char number [ ] ) { int n = strlen ( number ) ; int d [ 9 ] ; memset ( d , 0 , sizeof ( d ) ) ; d [ 0 ] = 1 ; int result = 0 ; int mod_sum = 0 , continuous_zero = 0 ; for ( int i = 0 ; i < n ; i ++ ) { if ( ! int ( number [ i ] - '0' ) ) continuous_zero ++ ; else continuous_zero = 0 ; mod_sum += int ( number [ i ] - '0' ) ; mod_sum %= 9 ; result += d [ mod_sum ] ; d [ mod_sum ] ++ ; result -= continuous_zero ; } return result ; } int main ( ) { cout << count9s ( "01809" ) << endl ; cout << count9s ( "1809" ) << endl ; cout << count9s ( "4189" ) ; return 0 ; }

Index/key variables: i, mod_sum
Accumulator variables: continuous_zero, i, mod_sum, result
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string maximumNum ( string curr_num , string res ) { int len1 = curr_num . length ( ) ; int len2 = res . length ( ) ; if ( len1 == len2 ) { int i = 0 ; while ( curr_num [ i ] == res [ i ] ) i ++ ; if ( curr_num [ i ] < res [ i ] ) return res ; else return curr_num ; } return len1 < len2 ? res : curr_num ; } string extractMaximum ( string str ) { int n = str . length ( ) ; string curr_num = " " ; string res ; for ( int i = 0 ; i < n ; i ++ ) { while ( i < n && str [ i ] == '0' ) i ++ ; while ( i < n && str [ i ] >= '0' && str [ i ] <= '9' ) { curr_num = curr_num + str [ i ] ; i ++ ; } if ( i == n ) break ; if ( curr_num . size ( ) > 0 ) i -- ; res = maximumNum ( curr_num , res ) ; curr_num = " " ; } if ( curr_num . size ( ) == 0 && res . size ( ) == 0 ) res = res + '0' ; return maximumNum ( curr_num , res ) ; } int main ( ) { string str = "100klh564abc365bg " ; cout << extractMaximum ( str ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isDivisible999 ( string num ) { int n = num . length ( ) ; if ( n == 0 && num [ 0 ] == '0' ) return true ; if ( n % 3 == 1 ) num = "00" + num ; if ( n % 3 == 2 ) num = "0" + num ; int gSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) { int group = 0 ; group += ( num [ i ++ ] - '0' ) * 100 ; group += ( num [ i ++ ] - '0' ) * 10 ; group += num [ i ] - '0' ; gSum += group ; } if ( gSum > 1000 ) { num = to_string ( gSum ) ; n = num . length ( ) ; gSum = isDivisible999 ( num ) ; } return ( gSum == 999 ) ; } int main ( ) { string num = "1998" ; int n = num . length ( ) ; if ( isDivisible999 ( num ) ) cout << " Divisible " ; else cout << " Not ▁ divisible " ; return 0 ; }

Index/key variables: i
Accumulator variables: gSum, group, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX_CHAR = 26 ; string arrangeString ( string str ) { int char_count [ MAX_CHAR ] = { 0 } ; int sum = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] >= ' A ' && str [ i ] <= ' Z ' ) char_count [ str [ i ] - ' A ' ] ++ ; else sum = sum + ( str [ i ] - '0' ) ; } string res = " " ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) { char ch = ( char ) ( ' A ' + i ) ; while ( char_count [ i ] -- ) res = res + ch ; } if ( sum > 0 ) res = res + to_string ( sum ) ; return res ; } int main ( ) { string str = " ACCBA10D2EW30" ; cout << arrangeString ( str ) ; return 0 ; }

Index/key variables: MAX_CHAR, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void subString ( char str [ ] , int n ) { for ( int len = 1 ; len <= n ; len ++ ) { for ( int i = 0 ; i <= n - len ; i ++ ) { int j = i + len - 1 ; for ( int k = i ; k <= j ; k ++ ) cout << str [ k ] ; cout << endl ; } } } int main ( ) { char str [ ] = " abc " ; subString ( str , strlen ( str ) ) ; return 0 ; }

Index/key variables: k
Accumulator variables: i, k, len, stdc
Iterator variables: i, k, len
C++ program:
#include <iostream>
using namespace std ; string reverses ( string str ) { int n = str . size ( ) ; string result ( n , ' \0' ) ; for ( int i = 0 ; i < n ; i ++ ) if ( str [ i ] == ' ▁ ' ) result [ i ] = ' ▁ ' ; int j = n - 1 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str [ i ] != ' ▁ ' ) { if ( result [ j ] == ' ▁ ' ) j -- ; result [ j ] = str [ i ] ; j -- ; } } return result ; } int main ( ) { string str = " internship ▁ at ▁ geeks ▁ for ▁ geeks " ; cout << reverses ( str ) << endl ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; const int MAX_CHAR = 26 ; void findAndPrintUncommonChars ( string str1 , string str2 ) { int present [ MAX_CHAR ] ; for ( int i = 0 ; i < MAX_CHAR ; i ++ ) present [ i ] = 0 ; int l1 = str1 . size ( ) ; int l2 = str2 . size ( ) ; for ( int i = 0 ; i < l1 ; i ++ ) present [ str1 [ i ] - ' a ' ] = 1 ; for ( int i = 0 ; i < l2 ; i ++ ) { if ( present [ str2 [ i ] - ' a ' ] == 1 present [ str2 [ i ] - ' a ' ] == -1 ) present [ str2 [ i ] - ' a ' ] = -1 ; else present [ str2 [ i ] - ' a ' ] = 2 ; } for ( int i = 0 ; i < MAX_CHAR ; i ++ ) if ( present [ i ] == 1 present [ i ] == 2 ) cout << ( char ( i + ' a ' ) ) << " ▁ " ; } int main ( ) { string str1 = " characters " ; string str2 = " alphabets " ; findAndPrintUncommonChars ( str1 , str2 ) ; return 0 ; }

Index/key variables: MAX_CHAR, i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#include <boost/algorithm/string.hpp>
using namespace std ; int lengthOfLastWord ( string a ) { int len = 0 ; string str ( a ) ; boost :: trim_right ( str ) ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) { if ( str . at ( i ) == ' ▁ ' ) len = 0 ; else len ++ ; } return len ; } int main ( ) { string input = " Geeks ▁ For ▁ Geeks ▁ " ; cout << " The ▁ length ▁ of ▁ last ▁ word ▁ is ▁ " << lengthOfLastWord ( input ) ; }

Accumulator variables: i, len, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; bool isVowel ( char ch ) { ch = toupper ( ch ) ; return ( ch == ' A ' ch == ' E ' ch == ' I ' ch == ' O ' ch == ' U ' ) ; } int countVowels ( string str ) { int count = 0 ; for ( int i = 0 ; i < str . length ( ) ; i ++ ) ++ count ; return count ; } int main ( ) { string str = " abc ▁ de " ; cout << countVowels ( str ) << endl ; return 0 ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; char * toggleCase ( char * a ) { for ( int i = 0 ; a [ i ] != ' \0' ; i ++ ) { a [ i ] ^= 32 ; } return a ; } int main ( ) { char str [ ] = " CheRrY " ; cout << " Toggle ▁ case : ▁ " << toggleCase ( str ) << endl ; cout << " Original ▁ string : ▁ " << toggleCase ( str ) << endl ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool uniqueCharacters ( string str ) { set < char > char_set ; for ( char c : str ) { char_set . insert ( c ) ; } if ( char_set . size ( ) == str . size ( ) ) { return true ; } else { return false ; } } int main ( ) { string str = " GeeksforGeeks " ; if ( uniqueCharacters ( str ) ) { cout << " The ▁ String ▁ " << str << " ▁ has ▁ all ▁ unique ▁ characters STRNEWLINE " ; } else { cout << " The ▁ String ▁ " << str << " ▁ has ▁ duplicate ▁ characters STRNEWLINE " ; } return 0 ; }

Accumulator variables: stdc
Iterator variables: c
C++ program:
#include <iostream>
using namespace std ; void concatenate ( char a [ ] , char b [ ] , char c [ ] , int n1 , int n2 ) { int i ; for ( i = 0 ; i < n1 ; i ++ ) c [ i ] = a [ i ] ; for ( int j = 0 ; j < n2 ; j ++ ) c [ i ++ ] = b [ j ] ; c [ i ] = ' \0' ; } int main ( ) { char a [ ] = " Hi ▁ This ▁ is ▁ geeksforgeeks . ▁ " ; int n1 = sizeof ( a ) / sizeof ( a [ 0 ] ) ; char b [ ] = " You ▁ are ▁ welcome ▁ here . " ; int n2 = sizeof ( b ) / sizeof ( b [ 0 ] ) ; char c [ n1 + n2 - 1 ] ; concatenate ( a , b , c , n1 , n2 ) ; for ( int i = 0 ; i < n1 + n2 - 1 ; i ++ ) cout << c [ i ] ; return 0 ; }

Index/key variables: i, j
Accumulator variables: i, j
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; void toggleChars ( string & S ) { for ( auto & it : S ) { if ( isalpha ( it ) ) { it ^= ( 1 << 5 ) ; } } } int main ( ) { string S = " GeKf @ rGeek $ " ; toggleChars ( S ) ; cout << " String ▁ after ▁ toggle ▁ " << endl ; cout << S << endl ; return 0 ; }

Accumulator variables: it, stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; string nextGreaterWithSameDigits ( string bnum ) { int l = bnum . size ( ) ; int i ; for ( int i = l - 2 ; i >= 1 ; i -- ) { if ( bnum . at ( i ) == '0' && bnum . at ( i + 1 ) == '1' ) { char ch = bnum . at ( i ) ; bnum . at ( i ) = bnum . at ( i + 1 ) ; bnum . at ( i + 1 ) = ch ; break ; } } if ( i == 0 ) " no ▁ greater ▁ number " ; int j = i + 2 , k = l - 1 ; while ( j < k ) { if ( bnum . at ( j ) == '1' && bnum . at ( k ) == '0' ) { char ch = bnum . at ( j ) ; bnum . at ( j ) = bnum . at ( k ) ; bnum . at ( k ) = ch ; j ++ ; k -- ; } else if ( bnum . at ( i ) == '0' ) break ; else j ++ ; } return bnum ; } int main ( ) { string bnum = "10010" ; cout << " Binary ▁ representation ▁ of ▁ next ▁ greater ▁ number ▁ = ▁ " << nextGreaterWithSameDigits ( bnum ) ; return 0 ; }

Accumulator variables: i, j, k, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void printRotatedString ( char str [ ] ) { int len = strlen ( str ) ; char temp [ len ] ; for ( int i = 0 ; i < len ; i ++ ) { int j = i ; int k = 0 ; while ( str [ j ] != ' \0' ) { temp [ k ] = str [ j ] ; k ++ ; j ++ ; } j = 0 ; while ( j < i ) { temp [ k ] = str [ j ] ; j ++ ; k ++ ; } printf ( " % s STRNEWLINE " , temp ) ; } } int main ( ) { char str [ ] = " geeks " ; printRotatedString ( str ) ; return 0 ; }

Index/key variables: j, k, len
Accumulator variables: i, j, k, stdc
Iterator variables: i