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

3Sum - Leetcode solution - How i turned into two-pointer approach?

  class Solution {     public List < List < Integer >> threeSum ( int [] nums ) {         Arrays . sort (nums); // first sort...