algorithms

2’s Complement – C Program

We can obtain 2’s complement in atleast two ways through a C program. If n is a number then -n will give the result. The next approach is to first flip all the bits (1’s complement) and then add 1. The bits can be flipped using ~ operator. The program below demonstrates both the approaches.

General Discussions

That Day of Machines

The day stands ahead. That day, where it would be difficult to judge on who deceived us. Was it a machine or a man? Was it a machine who said it was a man and deceived us OR was it a man who behaved like a machine and deceived us? The line is thin. The… Continue reading That Day of Machines

algorithms

Bubble, Selection and Insertion Sorts – C

This post presents the C program of three basic sorting techniques. Bubble Sort: Selection Sort: Insertion Sort:

General Discussions

Human Problem Solving

Originally posted on PH Bytes:
The Process Machine solving should not be like a magic making process. Along with result, it is equally important to know the process by which the results were obtained. The thinking process of the machine must be like the way we humans do. The way humans have patterns in their…

algorithms

Check if Number is Odd Using Bitwise – C

An odd number always has the LSB set to 1. If we AND the given number with 1, the even number will always turn out to be zero. We can using this to check if the number is odd or even. Examples: 1) n = 4 100     (4) 001     (1) ———– AND 000… Continue reading Check if Number is Odd Using Bitwise – C

General Discussions

Machine Learning to Machine Reasoning

Originally posted on PH Bytes:
Learning and Reasoning are two essential abilities associated with intelligence. As humans we see a scene, we hear a sentence and we just know what they mean. We can learn and we can take decisions based on reasoning. Bringing this capability to machine is a challenging task. The efforts have…

algorithms

Case Conversion using Bitwise – C Programs

Refer to theory HERE. Program to Convert Upper Case to Lower Case: Program to Convert Lower Case to Upper Case:

algorithms

Case Conversion using Bitwise – C

We generally use the functions strlwr() and strupr() available under string.h to toggle between the cases. This can also be achieved using bitwise operations. Before that, lets understand the ASCII table. ASCII of A is 65 (1000001) ASCII of a is 97 (1100001) Similarly, ASCII of Z is 97   (1011010) ASCII of z is 122 (1111010)… Continue reading Case Conversion using Bitwise – C

algorithms

Pointer and Types – C

This note covers various types of pointers to be aware of and a few notations used with pointers. Types of Pointers Pointer: Pointer is a variable which holds the address of another variable NULL Pointer: A null pointer has a value reserved for indicating that the pointer does not refer to a valid object. It… Continue reading Pointer and Types – C