Pages

Saturday, April 5, 2025

Output and Input of Arrays in C++

#include<iostream>
using namespace std;

int main(){
    int arr[5] = {7, 5, 2, 1 , 3};
    int n = sizeof(arr) / sizeof(int);
    for(int i = 0; i < n ; i++)
    {
    cout << arr[i] << " "; // idx = 0, 1, 2, 3, 4
    }
    cout << endl;
    return 0;

} 


OUTPUT- 

7 5 2 1 3 

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...