Skip to main content

Posts

Showing posts with the label windows

How to add 2 numbers without using an arithmetic operator?

 Guess you have to add two integers or numbers but without using the arithmetic operator. You cannot use any arithmetic operator like +, -, ++, --, ... etc. How will you do that? This question was asked in Microsoft Online Assessment. For solving this problem we have to go back to our Digital Electronics concepts where for adding two bits, we can do the XOR(^) of those bits. if they have a carry, we can find that out by applying AND(&) of them. So, this is the simple concept of Half Adder  which is used to add 2 single bits.  Input: 3 5 Output: 8 C++ code for this problem: #include   <bits/stdc++.h> using   namespace   std ; int   main () {      int  x, y, carry;     cin  >>  x  >>  y;      while  (y  !=   0 )     {         carry  =  x  &  ...

Setting up Cpp environment on VS Code | Windows 10

I have recently switched to Windows 10 from PopOs ( a Debian-based Linux) because of my project-related work which could not be done in any Debian-based Linux. So, I installed windows 10 on my system and it was just a little annoying but cool as well because my system's performance has increased (which was obvious as I have deleted all my previous data just backed up around 60Gb of it). So, starting with the process of setting up the environment for C++ on the VS Code on Windows 10. In Linux, I used to run C++ files on Sublime text only but on Windows, I'm just using VS code for both C++ and JavaScript. Let's start setting up the environment. I am dividing this whole process into 4 steps: First, you have to set up a compiler for the system. As we know that C/C++ is compiled programming language which requires a compiler to make them compiled and run. In Linux, there is already a gcc/g++ compiler preinstalled. But in Windows, you have to install it separately. So you can dow...