Pages

Monday, March 31, 2025

Scope (local vs global) functions in C++

 #include <iostream>

using namespace std;


int num = 25;
void sum(int a, int b) {
    cout << num << endl;
    int s = a + b;
    cout << s << endl;
}


int main(){
    sum(5, 4);
    int s = 10;

    cout << num << endl;

    return 0;
}

No comments:

Post a Comment

3917. Count Indices With Opposite Parity (Brute Force) O(n2) + Optimized Solution O(n) + tips LEETCODE WEEKLY 500

  class Solution {     public int [] countOppositeParity ( int [] nums ) {          // approach 1 - checks every pair         int n = n...