Introduction to Newbie Programmer Series Introduction to Computer The Computer Programming Language Setting up the Computer for Programming
 Lets Get Started !
Beginning C Programming Variables a Handbag ! Basic Variable types in C Basic Formatted Output Basic Formatted Input
Looping Repeating Concept Different Kinds of Loops Advanced concepts and trick with Loops
Operators, An Introduction Arithmetic Operators Relational Operators Logical Operators Bitwise Operators Miscellaneous Operators and Operators Precedence
 Controlling the Flow
Flow Charts Conditional Statements Using Goto and Label Break and Continue the loops Switch the Cases Some Practical Applications of Control Flow
 The program structure
The program Structure Functions More Concepts of Functions Scope of the Variables across functions How the C language itself Works ? Scope of the Variables across files Static Variables Auto and Register Variables #define PreProcessor Some more PreProcessors
 Arrays and Structures
Introduction to Arrays Arrays, some more Concepts Arrays, Cool Examples Structures Introduction Structure, Some more Concepts Structure, Some Examples
 File Management
Basics of File management in C Steps Involved with File Handling in C
Inside Logic Gates – The Electronic Logic Binary Number System Mathematical Reasoning
Newbie Programmer
full book coming soon
by Shubham Ramdeo

Maths is not only for addition and subtraction, it can really do have logical sense ! Mathematical Reasoning can do that !

Mathematical Reasoning

Mathematics ! Some of you might feel excited as we are discussing some Mathematics at a Programming Blog. While I believe most of you will hate and say, maths here too ?!?!

Well the truth is, yes ! Maths is everywhere. Even in Logic and Reasoning. And that's what we are gonna discuss today.  As always, this miscellaneous post is not intended, its gonna be useful before going into Bitwise Operators of our Newbie Programmer Series. But I think you will like this introduction to a new form of mathematics. Before reading this, I will recommend you to read a recent post of mine about Electronic Logic (click here). That will help you a lot to understand all this.

Mathematical Reasoning is a branch of applied mathematics. That means here we apply mathematics to make our work done. With Mathematical Reasoning, we can use mathematics over logical analysis.

We will discuss only those simple things which are useful to Newbie Programmer Series and will skip the advanced parts

The Statements

Just as we did in a recent post "The Electronic Logic" (click here) Here too, we have three things :

For example :
  • p : "Sun rises in the east." It is a True Statement. So ( 1 )
  • q : "Moon looks Orange." It is a False Statement. So ( 0 )
  • r : "How beautiful the sky is !" It is not a statement.

Truth Tables

This is a very simple thing. Here we simply write Combinations of T if True and F if False for the statements to analyse them.
So as above we have three statements, p, q and r.
Suppose we want to make Combinations of statements p and q then :
p    q
T   T
T   F
F   T
F   F
And you see we got all the combinations of T and F that can we get with p and q statements.

NOT ( ~ ) : Negation of a statement

This is again simple. It reverses T to F and F to T. It says the statement is logically correct if we perform the opposite of it. (click here to learn more). 
So if p is a statement, ~p is its negative.
Like p : "Sun rises in the East"
Then ~p : "Sun do not rise in the East"
Its table is like :
p   ~p
T   F
F   T

Compound Statements

We can connect two or more statements using connectives such as AND OR etc. Like "I like bread and butter" is a compound statement of "I like bread" and "I like Butter"


Its actual symbol is ( ^ ) but in programming purpose, we use ( & ). The compound statement with AND is true if both the statements are true.
Its truth table is like :
p    q   p&q
T   T    T
T   F    F
F   T    F
F   F    F
For example:
Use the above truth table and check the answers of the below statements.
"Sun is round and Hot" TRUE as both statements are true.
"Sun is round and white" FALSE
"Sun is square and Hot" FALSE
"Sun is square and white" FALSE


Again for our programming purpose, we are gonna use the symbol ( | ). The compound statement with OR is true if at least one of them is true.
Its truth table is like :
p    q   p|q
T   T    T
T   F    T
F   T    T
F   F    F
For example:
Use the above table and check the answers of the below statements.
Suppose there is a Computer Science Engineering Student. So he study Science and Maths only. Now :
"He study science or maths" TRUE
"He study science or history" TRUE
"He study economics or maths" TRUE
"He study economics or history" FALSE

XOR : The exclusive OR

It's a different type of OR. It says that if one event happens, other automatically get skipped.
For example, when we say:
"He study Science or Maths" He can study both the subjects at the same time too.
But if we say:
"He arrived school by Bus or Taxi" Here he cannot do both the things together. So if he came taxi, the event of coming in Bus automatically get FALSed.

I think that's enough... for now...

And that's all was the basic Mathematical Reasoning that I wanted to teach you before learning the Bitwise Operators in Newbie Programmer Series. That's all just the pre-required basics. There are lots of advanced things in this topic but I don't want to make my blog being hated out of so much Mathematics !
The next post is surely gonna be Bitwise Operators. So stay connected ! If any doubt, ask me at @ramdeoshubham

Please share this as much as you can so that we can get connected with more and more people who want to learn programming.

© Shubham Ramdeo

Site Map
© Shubham Ramdeo