Logical operators in C

Relational operators are good at comparing two quantities. However, relational operators does not support comparison of three or more quantities.

For example, suppose you need to check range of a number. You need to check whether a number n is in between 1-100 or not. For that you must check two conditions, first check if n > 1 finally check if n < 100.

We use logical operators to combine two or more relational expressions as a single relational expression. Logical operators evaluates a Boolean value (integer in case of C) depending upon the operator used.

Read more

Relational operators in C

In real life, we often compare two different quantities and depending on their relation, we take some decisions. For example, we compare the price of two items, age of two persons etc. Relational operators supports these comparisons in C programming.

We use relational operators to compare two constants, variables or expressions. We generally compare two quantities of similar nature. Likewise, relational operators can only compare any two similar types. It evaluates Boolean value either true or false depending on their relation. Based on evaluated Boolean result we take decisions or execute some statements.

In C programming, there is no concept of Boolean values. C represents false with 0 and true with a non-zero integer value.

Read more

Arithmetic operators in C

Arithmetic operators are used to perform basic arithmetic operations. Operations like addition, subtraction, multiplication, division and modulo division.

C supports five arithmetic operators.

OperatorDescription
+Unary plus or binary addition
-Unary minus or binary subtraction
*Multiplication
/Division
%Modulo division (Evaluates remainder)

Read more

Keywords and Identifiers in C programming

In previous post, we executed our first C program. That was interesting and a stepping-stone towards complex C programs.

A C program consists of various programming elements. These programming elements are the building blocks of any simple or complex application. Programming elements such as keyword, identifier, operator, expression, constant etc.

In this section and subsections, I am will cover all fundamental programming elements of a C program.

Read more

The C compilation process

In the series of C tutorial we learned some basic of C programming language, configured C compiler and learned to compile and execute C program.

Since the compilation and execution of first C program, I must answer few questions before moving ahead. Questions such as – what is meant by compilation, what happens during compilation, how a simple plain text file gets converted to executable binary file.

In this post I will take a deep dive into the C compilation process. So let’s begin.

Read more

Various declarations of main() function in C

main() is a special function in C programming language. Reasons that make it special are –

  • It defines starting point of the program.
  • main is the first executed function.
  • It controls all other child functions.
  • Behaves as both user-defined and pre-defined function.
  • Every software written in C must have a main function.

C is a popular programming language. There exist many compilers and standards for C. So exists many variants of main function declaration. In this post we will learn various declarations of main one by one. Later we will see the standard definition of the main function in C.

Read more

How to create and run C program using CodeBlocks

Compiling and executing C programs using command prompt has always been a nightmare to programmers. It is time taking process.

Once you got strong hold to compile and execute C programs using command line, it’s time to switch to IDE. However, I always recommend a beginner to use command prompt for sometime for compiling and executing C programs.

CodeBlocks is a powerful IDE for creating, compiling, executing and debugging C/C++ programs. In previous post, I explained installation and configuration of CodeBlocks. In this post we will move further and see how to create, compile and run a C program in CodeBlocks.

Read more