Message from C, C++ talks

July 2019

— Https://

— 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 gets false

Message permanent page


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;
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){
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;


— **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

— Last one is assigned dats what i read