Pages

Tuesday, April 22, 2025

Char Array (for each loop) in C++

#include <iostream>

#include <cstring>

using namespace std;



int main()

{

    string str = "apna college";

    

    

    // for(int i=0; i<str.length(); i++) {

    //     cout << str[i] << "-";

        

    // } cout << "\n";

        

        for(char ch : str) {

            cout << ch << ",";

        } cout << endl;

    

    // for(char ch : str) {

    //     cout << ch << ",";

    // }

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