Message from C, C++ talks

July 2019

— Oh, wait sry, I thought it's you asked the initial question :)

— Https://en.cppreference.com/w/cpp/language/operator_other#Built-in_comma_operator

— Its comma operator... Google it

— Comma can be used as an operator too ...

— 

If statement gets executed only when it gets its condition true(i.e 1 ) so by initialisation i =1, the if statement will be executed ....if u assign any other value then non zero value it will get executed ...but when u assign 0 ...it gets false

— Https://www.spoj.com/problems/BSEARCH1/
Can somebody help me with uploading this problem's solution in spoj. I am fairly new in competitive programming .In this binary search problem my code is running fine, outside in my local compiler but I am unable to know why my code is not accepted by the spoj. Help me out. Here is my code: #include <bits/stdc++.h>
using namespace std;

int arr[100],numberOfElemenets;

int BinarySearch(int x){
int mid,left=0,right=numberOfElemenets;
while(left<=right){
mid=(left+right)/2;
if(arr[mid]==x) return mid;
else if (arr[mid]>x) right = mid-1;
else left = mid +1;
}
return -1;
}

int main() {
int n;
cout<<"Enter the number of elements: ";
cin >> n;
for(int i=0 ; i<n ; ++i){
cin>>arr[i];
}
for(int i=0 ; i<n ; ++i){
cout<<arr[i]<<" ";
}
cout<< endl;
cout<<"The elements is present at :"<<BinarySearch(2)<<endl;
cout<<"The elements is present at :"<<BinarySearch(4)<<endl;
cout<<"The elements is present at :"<<BinarySearch(8)<<endl;

}

Message permanent page

— **Any value except than zero is true

— How does value of m is calculated

— Int n = 1;
int m = (++n, std::cout << "n = " << n << '\n', ++n, 2*n);

— Yess

— 👍

— ++n is first evaluate although its result is discarded

— So n becomes 2

— Yes

— What after that