Posts

Showing posts from January, 2022

Tricky Programs

Image
  1.        Print “Hello” without using a ;(semi-colon) in c/c++   #include <stdio.h> int main(){    if(printf("Hello "))    return 0; }   2. To check if two numbers are equal without using arithmetic operators or comparison operators. The simplest solution for this is using Bitwise XOR operator (^). For two equal numbers XOR operator returns 0 as all bits would be same and XOR of equal bits is 0. #include <iostream> using namespace std; int main() {    int x = 10;    int y = 10;    if (!(x ^ y))       cout << " x is equal to y ";    else       cout << " x is not equal to y ";    return 0; }   3.        To check if the given number is even without using arithmetic or relational operators.   #include<iostream> using namespace std; int main(){    int a = 154;    if(a & 1) {       cout<<a<<" is an odd number";    } else{       cout<<a<