dhyuti-n/xlcost-variable-roles huggingface dataset:
C++ program:
#include <bits/stdc++.h>
using namespace std ; #define MAX  100
void add ( char v1 [ ] , char v2 [ ] ) { int i , d , c = 0 ; int l1 = strlen ( v1 ) ; int l2 = strlen ( v2 ) ; for ( i = l1 ; i < l2 ; i ++ ) v1 [ i ] = '0' ; for ( i = l2 ; i < l1 ; i ++ ) v2 [ i ] = '0' ; for ( i = 0 ; i < l1 i < l2 ; i ++ ) { d = ( v1 [ i ] - '0' ) + ( v2 [ i ] - '0' ) + c ; c = d / 10 ; d %= 10 ; v1 [ i ] = '0' + d ; } while ( c ) { v1 [ i ] = '0' + ( c % 10 ) ; c /= 10 ; i ++ ; } v1 [ i ] = ' \0' ; v2 [ l2 ] = ' \0' ; } void subs ( char v1 [ ] , char v2 [ ] ) { int i , d , c = 0 ; int l1 = strlen ( v1 ) ; int l2 = strlen ( v2 ) ; for ( i = l2 ; i < l1 ; i ++ ) v2 [ i ] = '0' ; for ( i = 0 ; i < l1 ; i ++ ) { d = ( v1 [ i ] - '0' - c ) - ( v2 [ i ] - '0' ) ; if ( d < 0 ) { d += 10 ; c = 1 ; } else c = 0 ; v1 [ i ] = '0' + d ; } v2 [ l2 ] = ' \0' ; i = l1 - 1 ; while ( i > 0 && v1 [ i ] == '0' ) i -- ; v1 [ i + 1 ] = ' \0' ; } int divi ( char v [ ] , int q ) { int i , l = strlen ( v ) ; int c = 0 , d ; for ( i = l - 1 ; i >= 0 ; i -- ) { d = c * 10 + ( v [ i ] - '0' ) ; c = d % q ; d /= q ; v [ i ] = '0' + d ; } i = l - 1 ; while ( i > 0 && v [ i ] == '0' ) i -- ; v [ i + 1 ] = ' \0' ; return c ; } void rev ( char v [ ] ) { int l = strlen ( v ) ; int i ; char cc ; for ( i = 0 ; i < l - 1 - i ; i ++ ) { cc = v [ i ] ; v [ i ] = v [ l - 1 - i ] ; v [ l - i - 1 ] = cc ; } } void divideWithDiffK ( char a [ ] , char k [ ] ) { rev ( a ) ; rev ( k ) ; add ( a , k ) ; divi ( a , 2 ) ; rev ( a ) ; cout << " ▁ " << a ; rev ( a ) ; subs ( a , k ) ; rev ( a ) ; cout << " ▁ " << a ; } int main ( ) { char a [ MAX ] = "100" , k [ MAX ] = "20" ; divideWithDiffK ( a , k ) ; return 0 ; }

Index/key variables: MAX, i, l2
Accumulator variables: c, d, i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int fnMod ( int n ) { if ( n % 5 == 1 ) return 4 ; else return 0 ; } int main ( ) { int n = 10 ; cout << fnMod ( n ) << endl ; n = 11 ; cout << fnMod ( n ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int digSum ( int n ) { if ( n == 0 ) return 0 ; return ( n % 9 == 0 ) ? 9 : ( n % 9 ) ; } int repeatedNumberSum ( int n , int x ) { int sum = x * digSum ( n ) ; return digSum ( sum ) ; } int main ( ) { int n = 24 , x = 3 ; cout << repeatedNumberSum ( n , x ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <cmath>
#include <iostream>
using namespace std ; int totalSumDivisibleByNum ( int n , int number ) { int firstnum = pow ( 10 , n - 1 ) ; int lastnum = pow ( 10 , n ) ; int sum = 0 ; for ( int i = firstnum ; i < lastnum ; i ++ ) if ( i % number == 0 ) sum += i ; return sum ; } int main ( ) { int n = 3 , num = 7 ; cout << totalSumDivisibleByNum ( n , num ) << " STRNEWLINE " ; return 0 ; }

Accumulator variables: i, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; string fractionToDecimal ( int numerator , int denominator ) { string res ; unordered_map < int , int > mp ; int rem = numerator % denominator ; while ( ( rem != 0 ) && ( mp . find ( rem ) == mp . end ( ) ) ) { mp [ rem ] = res . length ( ) ; rem = rem * 10 ; int res_part = rem / denominator ; res += to_string ( res_part ) ; rem = rem % denominator ; } return ( rem == 0 ) ? " - 1" : res . substr ( mp [ rem ] ) ; } bool isPrime ( int n ) { for ( int i = 2 ; i <= n / 2 ; i ++ ) if ( n % i == 0 ) return false ; return true ; } void ExtendedMidys ( string str , int n , int m ) { if ( ! isPrime ( n ) ) { cout << " Denominator ▁ is ▁ not ▁ prime , ▁ " << " thus ▁ Extended ▁ Midy ' s ▁ " << " theorem ▁ is ▁ not ▁ applicable " ; return ; } int l = str . length ( ) ; int part1 = 0 , part2 = 0 ; if ( l % 2 == 0 && l % m == 0 ) { int part [ m ] = { 0 } , sum = 0 , res = 0 ; for ( int i = 0 ; i < l ; i ++ ) { int var = i / m ; part [ var ] = part [ var ] * 10 + ( str [ i ] - '0' ) ; } for ( int i = 0 ; i < m ; i ++ ) { sum = sum + part [ i ] ; cout << part [ i ] << " ▁ " ; } cout << endl ; res = pow ( 10 , m ) - 1 ; if ( sum % res == 0 ) cout << " Extended ▁ Midy ' s ▁ theorem ▁ holds ! " ; else cout << " Extended ▁ Midy ' s ▁ theorem " << " ▁ doesn ' t ▁ hold ! " ; } else if ( l % 2 != 0 ) { cout << " The ▁ repeating ▁ decimal ▁ is " << " ▁ of ▁ odd ▁ length ▁ thus ▁ Extended ▁ " << " Midy ' s ▁ theorem ▁ is ▁ not ▁ applicable " ; } else if ( l % m != 0 ) { cout << " The ▁ repeating ▁ decimal ▁ can ▁ " << " not ▁ be ▁ divided ▁ into ▁ m ▁ digits " ; } } int main ( ) { int numr = 1 , denr = 17 , m = 4 ; string res = fractionToDecimal ( numr , denr ) ; if ( res == " - 1" ) cout << " The ▁ fraction ▁ does ▁ not " << " ▁ have ▁ repeating ▁ decimal " ; else { cout << " Repeating ▁ decimal ▁ = ▁ " << res << endl ; ExtendedMidys ( res , denr , m ) ; } return 0 ; }

Index/key variables: i, m, rem, var
Accumulator variables: i, res, stdc
Iterator variables: i
C++ program:
#include <cmath>
#include <iostream>
using namespace std ; int numberofterm ( int n , int number ) { int firstnum = pow ( 10 , n - 1 ) ; int lastnum = pow ( 10 , n ) ; int count = 0 ; for ( int i = firstnum ; i < lastnum ; i ++ ) if ( i % number == 0 ) count ++ ; return count ; } int main ( ) { int n = 3 , num = 7 ; cout << numberofterm ( n , num ) << " STRNEWLINE " ; return 0 ; }

Accumulator variables: count, i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void georgeCantor ( int n ) { int i = 1 ; int j = 1 ; int k = 1 ; while ( k < n ) { j ++ , k ++ ; if ( k == n ) break ; while ( j > 1 && k < n ) { i ++ , j -- , k ++ ; } if ( k == n ) break ; i ++ , k ++ ; if ( k == n ) break ; while ( i > 1 && k < n ) { i -- , j ++ , k ++ ; } } cout << " N - th ▁ term ▁ : ▁ " << i << " ▁ / ▁ " << j ; } int main ( ) { int n = 15 ; georgeCantor ( n ) ; return 0 ; }

Accumulator variables: i, j, k, stdc
C++ program:
#include <iostream>
using namespace std ; bool isDivisible ( long long int n ) { while ( n / 100 ) { int last_digit = n % 10 ; n /= 10 ; n += last_digit * 3 ; } return ( n % 29 == 0 ) ; } int main ( ) { long long int n = 348 ; if ( isDivisible ( n ) ) cout << " Yes " << endl ; else cout << " No " << endl ; return 0 ; }

Accumulator variables: n
C++ program:
#include <bits/stdc++.h>
using namespace std ; string solveEquation ( string equation ) { int n = equation . size ( ) , sign = 1 , coeff = 0 ; int total = 0 , i = 0 ; for ( int j = 0 ; j < n ; j ++ ) { if ( equation [ j ] == ' + ' equation [ j ] == ' - ' ) { if ( j > i ) total += sign * stoi ( equation . substr ( i , j - i ) ) ; i = j ; } else if ( equation [ j ] == ' x ' ) { if ( ( i == j ) equation [ j - 1 ] == ' + ' ) coeff += sign ; else if ( equation [ j - 1 ] == ' - ' ) coeff -= sign ; else coeff += sign * stoi ( equation . substr ( i , j - i ) ) ; i = j + 1 ; } else if ( equation [ j ] == ' = ' ) { if ( j > i ) total += sign * stoi ( equation . substr ( i , j - i ) ) ; sign = -1 ; i = j + 1 ; } } if ( i < n ) total += sign * stoi ( equation . substr ( i ) ) ; if ( coeff == 0 && total == 0 ) return " Infinite ▁ solutions " ; if ( coeff == 0 && total ) return " No ▁ solution " ; int ans = - total / coeff ; return " x = " + to_string ( ans ) ; } int main ( ) { string equation = " x + 5-3 + x = 6 + x - 2" ; cout << solveEquation ( equation ) ; return 0 ; }

Index/key variables: j
Accumulator variables: coeff, j, stdc, total
Iterator variables: j
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool pronic_check ( int n ) { int x = ( int ) ( sqrt ( n ) ) ; if ( x * ( x + 1 ) == n ) return true ; else return false ; } int main ( void ) { int n = 56 ; pronic_check ( n ) == true ? cout << " YES " : cout << " NO " ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; #define MAX  100000
int multiply ( int x , int res [ ] , int res_size ) { int carry = 0 ; for ( int i = 0 ; i < res_size ; i ++ ) { int prod = res [ i ] * x + carry ; res [ i ] = prod % 10 ; carry = prod / 10 ; } while ( carry ) { res [ res_size ] = carry % 10 ; carry = carry / 10 ; res_size ++ ; } return res_size ; } void power ( int x , int n ) { if ( n == 0 ) { cout << "1" ; return ; } int res [ MAX ] ; int res_size = 0 ; int temp = x ; while ( temp != 0 ) { res [ res_size ++ ] = temp % 10 ; temp = temp / 10 ; } for ( int i = 2 ; i <= n ; i ++ ) res_size = multiply ( x , res , res_size ) ; cout << x << " ^ " << n << " ▁ = ▁ " ; for ( int i = res_size - 1 ; i >= 0 ; i -- ) cout << res [ i ] ; } int main ( ) { int exponent = 100 ; int base = 20 ; power ( base , exponent ) ; return 0 ; }

Index/key variables: MAX, i, res_size
Accumulator variables: i, res_size
Iterator variables: i
C++ program:
#include <iostream>
#include <math.h>
using namespace std ; bool check ( int n , int p ) { int maximum = -1 ; while ( ! ( n % 2 ) ) { maximum = max ( maximum , 2 ) ; n = n / 2 ; } for ( int i = 3 ; i <= sqrt ( n ) ; i += 2 ) { while ( n % i == 0 ) { maximum = max ( maximum , i ) ; n = n / i ; } } if ( n > 2 ) maximum = max ( maximum , n ) ; return ( maximum <= p ) ; } int main ( ) { int n = 24 , p = 7 ; if ( check ( n , p ) ) cout << " yes " ; else cout << " no " ; return 0 ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; void find_time ( int h1 ) { int theta = 30 * h1 ; cout << " ( " << ( theta * 2 ) << " / " << "11" << " ) " << " ▁ minutes " ; } int main ( ) { int h1 = 3 ; find_time ( h1 ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sum_series ( int n ) { int nSquare = n * n ; return nSquare * ( nSquare - 1 ) / 4 ; } int main ( ) { int n = 2 ; cout << sum_series ( n ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
#include <cmath>
using namespace std ; bool isPrime ( int n ) { if ( n == 0 n == 1 ) return false ; int root = sqrt ( n ) ; for ( int i = 2 ; i <= root ; i ++ ) if ( n % i == 0 ) return false ; return true ; } bool isSandwitched ( int n ) { return ( isPrime ( n - 1 ) && isPrime ( n + 1 ) ) ; } int main ( ) { int n = 642 ; cout << n << " ▁ : ▁ " ; if ( isSandwitched ( n ) ) cout << " Yes STRNEWLINE " ; else cout << " No STRNEWLINE " ; n = 9 ; cout << n << " ▁ : ▁ " ; if ( isSandwitched ( n ) ) cout << " Yes STRNEWLINE " ; else cout << " No STRNEWLINE " ; return 0 ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int day_of_the_week ( int y , int m , int d ) { int t [ ] = { 0 , 3 , 2 , 5 , 0 , 3 , 5 , 1 , 4 , 6 , 2 , 4 } ; if ( m < 3 ) y -= 1 ; return ( ( y + y / 4 - y / 100 + y / 400 + t [ m - 1 ] + d ) % 7 ) ; } int main ( void ) { int day = 13 , month = 7 , year = 2017 ; cout << ( day_of_the_week ( year , month , day ) ) ; return 0 ; }

Accumulator variables: stdc, y
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isPrime ( int n , int i = 2 ) { if ( n <= 2 ) return ( n == 2 ) ? true : false ; if ( n % i == 0 ) return false ; if ( i * i > n ) return true ; return isPrime ( n , i + 1 ) ; } int main ( ) { int n = 15 ; if ( isPrime ( n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
C++ program:
# include <bits/stdc++.h>
using namespace std ; bool isSquareFree ( int n ) { if ( n % 2 == 0 ) n = n / 2 ; if ( n % 2 == 0 ) return false ; for ( int i = 3 ; i <= sqrt ( n ) ; i = i + 2 ) { if ( n % i == 0 ) { n = n / i ; if ( n % i == 0 ) return false ; } } return true ; } int main ( ) { int n = 10 ; if ( isSquareFree ( n ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; double findArea ( double d ) { return ( d * d ) / 2.0 ; } int main ( ) { double d = 10 ; cout << ( findArea ( d ) ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumOfSeries ( int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) sum = sum + ( 2 * i - 1 ) * ( 2 * i - 1 ) ; return sum ; } int main ( ) { int n = 10 ; cout << sumOfSeries ( n ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumOfSeries ( int n ) { return ( n * ( 2 * n - 1 ) * ( 2 * n + 1 ) ) / 3 ; } int main ( ) { int n = 10 ; cout << sumOfSeries ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float mean ( float arr [ ] , int n ) { float sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum = sum + arr [ i ] ; return sum / n ; } float SSD ( float arr [ ] , int n ) { float sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum = sum + ( arr [ i ] - mean ( arr , n ) ) * ( arr [ i ] - mean ( arr , n ) ) ; return sqrt ( sum / ( n - 1 ) ) ; } float sampleError ( float arr [ ] , int n ) { return SSD ( arr , n ) / sqrt ( n ) ; } int main ( ) { float arr [ ] = { 78.53 , 79.62 , 80.25 , 81.05 , 83.21 , 83.46 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << sampleError ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int StepstoReachTarget ( int target ) { target = abs ( target ) ; int n = ceil ( ( -1.0 + sqrt ( 1 + 8.0 * target ) ) / 2 ) ; int sum = n * ( n + 1 ) / 2 ; if ( sum == target ) return n ; int d = sum - target ; if ( ( d & 1 ) == 0 ) return n ; else return n + ( ( n & 1 ) ? 2 : 1 ) ; } int main ( ) { int target = 5 ; cout << StepstoReachTarget ( target ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; double seriesSum ( int n ) { int i = 1 ; double res = 0.0 ; bool sign = true ; while ( n > 0 ) { n -- ; if ( sign ) { sign = ! sign ; res = res + ( double ) ++ i / ++ i ; } else { sign = ! sign ; res = res - ( double ) ++ i / ++ i ; } } return res ; } int main ( ) { int n = 5 ; cout << seriesSum ( n ) ; return 0 ; }

Accumulator variables: n, stdc
Boolean variables: sign
C++ program:
#include <bits/stdc++.h>
unsigned int countSymmetric ( unsigned int n ) { if ( n == 0 ) return 1 ; return 1 << ( ( n * ( n + 1 ) ) / 2 ) ; } int main ( ) { unsigned int n = 3 ; printf ( " % u " , countSymmetric ( n ) ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int centeredNonagonal ( int n ) { return ( 3 * n - 2 ) * ( 3 * n - 1 ) / 2 ; } int main ( ) { int n = 10 ; cout << centeredNonagonal ( n ) ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; float Mean ( float arr [ ] , int n ) { float sum = 0 ; for ( int i = 0 ; i < n ; i ++ ) sum = sum + arr [ i ] ; return sum / n ; } float meanAbsoluteDeviation ( float arr [ ] , int n ) { float absSum = 0 ; for ( int i = 0 ; i < n ; i ++ ) absSum = absSum + abs ( arr [ i ] - Mean ( arr , n ) ) ; return absSum / n ; } int main ( ) { float arr [ ] = { 10 , 15 , 15 , 17 , 18 , 21 } ; int n = sizeof ( arr ) / sizeof ( arr [ 0 ] ) ; cout << meanAbsoluteDeviation ( arr , n ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; bool isRatioPossible ( int lowCost , int upCost , int lowQuant , int upQuant , int r ) { for ( int i = lowQuant ; i <= upQuant ; i ++ ) { int ans = i * r ; if ( lowCost <= ans && ans <= upCost ) return true ; } return false ; } int main ( ) { int lowCost = 14 , upCost = 30 , lowQuant = 5 , upQuant = 12 , r = 9 ; if ( isRatioPossible ( lowCost , upCost , lowQuant , upQuant , r ) ) cout << " Yes " ; else cout << " No " ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; void findNumbers ( int n , int d ) { for ( int i = 0 ; i < n - 2 ; i ++ ) cout << "1" << " ▁ " ; cout << "2" << " ▁ " ; cout << n + d << endl ; } int main ( ) { int N = 3 , D = 5 ; findNumbers ( N , D ) ; return 0 ; }

Accumulator variables: i
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long int oddNumSum ( int n ) { return ( n * ( 2 * n + 1 ) * ( 24 * n * n * n - 12 * n * n - 14 * n + 7 ) ) / 15 ; } int main ( ) { int n = 4 ; cout << oddNumSum ( n ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <iostream>
using namespace std ; bool isTrimorphic ( int N ) { int cube = N * N * N ; while ( N > 0 ) { if ( N % 10 != cube % 10 ) return false ; N /= 10 ; cube /= 10 ; } return true ; } int main ( ) { int N = 24 ; isTrimorphic ( N ) ? cout << " trimorphic " : cout << " not ▁ trimporphic " ; return 0 ; }

Accumulator variables: N, cube
C++ program:
#include <iostream>
using namespace std ; # define INT_MAX  2147483647
bool checkTrimorphic ( int num ) { int cube = num * num * num ; while ( num > 0 ) { if ( num % 10 != cube % 10 ) return false ; num /= 10 ; cube /= 10 ; } return true ; } int nthTrimorphic ( int n ) { int count = 0 ; for ( int i = 0 ; i < INT_MAX ; i ++ ) { if ( checkTrimorphic ( i ) ) count ++ ; if ( count == n ) return i ; } } int main ( ) { int n = 9 ; cout << nthTrimorphic ( n ) ; return 0 ; }

Accumulator variables: count, cube, i, num
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int reachTarget ( int target ) { target = abs ( target ) ; int sum = 0 , step = 0 ; while ( sum < target || ( sum - target ) % 2 != 0 ) { step ++ ; sum += step ; } return step ; } int main ( ) { int target = 5 ; cout << reachTarget ( target ) ; return 0 ; }

Accumulator variables: step, sum
C++ program:
#include <bits/stdc++.h>
using namespace std ; long long int fifthPowerSum ( int n ) { return ( ( 2 * n * n * n * n * n * n ) + ( 6 * n * n * n * n * n ) + ( 5 * n * n * n * n ) - ( n * n ) ) / 12 ; } int main ( ) { int n = 5 ; cout << fifthPowerSum ( n ) << endl ; return 0 ; }

Accumulator variables: stdc
C++ program:
#include <bits/stdc++.h>
using namespace std ; int unitDigitXRaisedY ( int x , int y ) { int res = 1 ; for ( int i = 0 ; i < y ; i ++ ) res = ( res * x ) % 10 ; return res ; } int main ( ) { cout << unitDigitXRaisedY ( 4 , 2 ) ; return 0 ; }

Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std ; typedef pair < float , float > Data ; typedef vector < Data > Vector ; float sigma_fx ( const Vector & v ) { float sum = 0 ; for ( auto i : v ) { sum += i . first * i . second ; } return sum ; } float sigma_f ( const Vector & v ) { float sum = 0.0 ; for ( auto i : v ) { sum += i . second ; } return sum ; } float calculate_mean ( const Vector & v ) { return sigma_fx ( v ) / sigma_f ( v ) ; } float calculate_std ( const Vector & v ) { float f = sigma_f ( v ) ; float mean = sigma_fx ( v ) / f ; float sum = 0 ; for ( auto i : v ) { sum += ( i . first - mean ) * ( i . first - mean ) * i . second ; } return sqrt ( sum / f ) ; } int main ( ) { Vector A = { { 0 , 0.1 } , { 100 , 0.1 } , { 200 , 0.2 } , { 333 , 0.3 } , { 400 , 0.3 } } ; Vector B = { { 100 , 0.1 } , { 200 , 0.5 } , { 700 , 0.4 } } ; float avg_A = calculate_mean ( A ) ; float avg_B = calculate_mean ( B ) ; float std_A = calculate_std ( A ) ; float std_B = calculate_std ( B ) ; cout << " For ▁ Investment ▁ A " << endl ; cout << " Average : ▁ " << avg_A << endl ; cout << " Standard ▁ Deviation : ▁ " << std_A << endl ; cout << " Normalised ▁ Std : ▁ " << std_A / avg_A << endl ; cout << " For ▁ Investment ▁ B " << endl ; cout << " Average : ▁ " << avg_B << endl ; cout << " Standard ▁ Deviation : ▁ " << std_B << endl ; cout << " Normalised ▁ Std : ▁ " << std_B / avg_B << endl ; ( std_B / avg_B ) < ( std_A / avg_A ) ? cout << " Investment ▁ B ▁ is ▁ less ▁ risky STRNEWLINE " : cout << " Investment ▁ A ▁ is ▁ less ▁ risky STRNEWLINE " ; return 0 ; }

Accumulator variables: sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; float AvgofSquareN ( int n ) { float sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) sum += ( i * i ) ; return sum / n ; } int main ( ) { int n = 2 ; cout << AvgofSquareN ( n ) ; return 0 ; }

Accumulator variables: i, stdc, sum
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumofFactors ( int n ) { if ( n % 2 != 0 ) return 0 ; int res = 1 ; for ( int i = 2 ; i <= sqrt ( n ) ; i ++ ) { int count = 0 , curr_sum = 1 , curr_term = 1 ; while ( n % i == 0 ) { count ++ ; n = n / i ; if ( i == 2 && count == 1 ) curr_sum = 0 ; curr_term *= i ; curr_sum += curr_term ; } res *= curr_sum ; } if ( n >= 2 ) res *= ( 1 + n ) ; return res ; } int main ( ) { int n = 18 ; cout << sumofFactors ( n ) ; return 0 ; }

Accumulator variables: count, curr_sum, curr_term, i, res, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int LCM ( int a , int b ) { return ( a * b ) / ( __gcd ( a , b ) ) ; } int lcmOfNumerator ( vector < pair < int , int > > vect ) { int lcm = vect [ 0 ] . first ; for ( int i = 1 ; i < vect . size ( ) ; i ++ ) lcm = LCM ( vect [ i ] . first , lcm ) ; return lcm ; } int gcdOfDemoninators ( vector < pair < int , int > > vect ) { int gcd = vect [ 0 ] . second ; for ( int i = 1 ; i < vect . size ( ) ; i ++ ) gcd = __gcd ( vect [ i ] . second , gcd ) ; return gcd ; } void lcmOfRationals ( vector < pair < int , int > > vect ) { cout << lcmOfNumerator ( vect ) << " / " << gcdOfDemoninators ( vect ) ; } int main ( ) { vector < pair < int , int > > vect ; vect . push_back ( make_pair ( 2 , 7 ) ) ; vect . push_back ( make_pair ( 3 , 14 ) ) ; vect . push_back ( make_pair ( 5 , 3 ) ) ; lcmOfRationals ( vect ) ; return 0 ; }

Index/key variables: i
Accumulator variables: i, stdc
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumofoddFactors ( int n ) { int res = 1 ; while ( n % 2 == 0 ) n = n / 2 ; for ( int i = 3 ; i <= sqrt ( n ) ; i ++ ) { int count = 0 , curr_sum = 1 ; int curr_term = 1 ; while ( n % i == 0 ) { count ++ ; n = n / i ; curr_term *= i ; curr_sum += curr_term ; } res *= curr_sum ; } if ( n >= 2 ) res *= ( 1 + n ) ; return res ; } int main ( ) { int n = 30 ; cout << sumofoddFactors ( n ) ; return 0 ; }

Accumulator variables: count, curr_sum, curr_term, i, res, stdc
Iterator variables: i
C++ program:
#include <iostream>
using namespace std ; int countSolutions ( int n , int val ) { int total = 0 ; if ( n == 1 && val >= 0 ) return 1 ; for ( int i = 0 ; i <= val ; i ++ ) { total += countSolutions ( n - 1 , val - i ) ; } return total ; } int main ( ) { int n = 5 ; int val = 20 ; cout << countSolutions ( n , val ) ; }

Accumulator variables: i, total
Iterator variables: i
C++ program:
#include <bits/stdc++.h>
#define N  6
using namespace std ; void fib ( int f [ ] , int n ) { int i ; f [ 0 ] = 0 ; f [ 1 ] = 1 ; for ( i = 2 ; i <= n ; i ++ ) f [ i ] = f [ i - 1 ] + f [ i - 2 ] ; } void fibcoef ( int fc [ ] [ N + 1 ] , int f [ ] , int n ) { for ( int i = 0 ; i <= n ; i ++ ) fc [ i ] [ 0 ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j <= i ; j ++ ) { int k = j ; while ( k -- ) fc [ i ] [ j ] *= f [ k ] ; k = 1 ; while ( ( j + 1 ) != k ) fc [ i ] [ j ] /= f [ k ++ ] ; } } } void printFibonomialTriangle ( int n ) { int f [ N + 1 ] = { 0 } ; fib ( f , n ) ; int dp [ N + 1 ] [ N + 1 ] = { 0 } ; for ( int i = 0 ; i <= n ; i ++ ) dp [ i ] [ 0 ] = dp [ i ] [ i ] = 1 ; for ( int i = 1 ; i <= n ; i ++ ) { for ( int j = 1 ; j < i ; j ++ ) dp [ i ] [ j ] = f [ i - j + 1 ] * dp [ i - 1 ] [ j - 1 ] + f [ j - 1 ] * dp [ i - 1 ] [ j ] ; } for ( int i = 0 ; i <= n ; i ++ ) { for ( int j = 0 ; j <= i ; j ++ ) cout << dp [ i ] [ j ] << " ▁ " ; cout << endl ; } } int main ( ) { int n = 6 ; printFibonomialTriangle ( n ) ; return 0 ; }

Index/key variables: i, j, k
Accumulator variables: i, j, k, stdc
Iterator variables: i, j
C++ program:
#include <bits/stdc++.h>
using namespace std ; int sumofNterm ( int a , int d , int b , int r , int n ) { int sum = 0 ; for ( int i = 1 ; i <= n ; i ++ ) sum += ( ( a + ( i - 1 ) * d ) * ( b * pow ( r , i - 1 ) ) ) ; return sum ; } int main ( ) { int a = 1 , d = 1 , b = 2 , r = 2 , n = 3 ; cout << sumofNterm ( a , d , b , r , n ) << endl ; return 0 ; }

Accumulator variables: i, stdc, sum
Iterator variables: i